11

I am accessing Pinterest API for getting user's information by using this url but I can not find that how to generate an access token for Pinterest.

According to this blog post, it says that

Pinterest uses OAuth2 to authenticate users

Can you please tell me, from where I can generate OAuth access tokens for Pinterest?

Robert MacLean
  • 38,975
  • 25
  • 98
  • 152
Dhruv
  • 1,862
  • 3
  • 20
  • 38

4 Answers4

8

First, register for an app and set up a redirect URI:

https://developers.pinterest.com/manage/

Then, find your client secret under Signature Tester:

https://developers.pinterest.com/tools/signature/

Bring the user to the OAuth dialog like this:

https://www.pinterest.com/oauth/?consumer_id=[client_id]&response_type=[code_or_token]&scope=[list_of_scopes]

If response type if token, it will be appended as a hash in the redirect URI.

If response type is code, see the post below for details on how to exchange code for token:

What's the auth code endpoint in Pinterest?

Community
  • 1
  • 1
Ben Wong
  • 1,987
  • 2
  • 19
  • 20
  • I want to authorize using https://www.pinterest.com/oauth/ please help below is my link https://pinterest.com/oauth/?consumer_id=4944452830850198488&redirect_uri=https%3A%2F%2Ftest.xxxxxx.com%2Fconnectpinterestboardapi&response_type=code&state=121213131312 Hi Guys my above links not working Which type of code need we do extra ? is app id consumer id? no then when I get consumer id? and my consumer id (app id) has more digits then yours Guys help me – Ankur Patel Jan 24 '18 at 06:20
4

You need to register a client app under manager Apps option in Dropdown menu when you login

or

https://developers.pinterest.com/manage/

Register your app and you get AppID.

This follow the process in this link you have

http://wiki.gic.mx/pinterest-developers/

Hope this helps

Pritesh Jain
  • 9,106
  • 4
  • 37
  • 51
2
**USING C#**

public string GetOAuthToken(string data)
    {
        string strResult = string.Empty;
        try
        {
                string Clientid = WebConfigurationManager.AppSettings["Pinterest_Clientid"];
                string ClientSecret = WebConfigurationManager.AppSettings["Pinterest_ClientSecret"];
                string uri_token = WebConfigurationManager.AppSettings["Pinterest_Uri_Token"];
                System.Net.HttpWebRequest req = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(uri_token);

                string parameters = "grant_type=authorization_code"
                                    + "&client_id="
                                    + Clientid
                                    + "&client_secret="
                                    + ClientSecret
                                    + "&code="
                                    + data;

                req.ContentType = "application/x-www-form-urlencoded";
                req.Method = "POST";
                byte[] bytes = Encoding.ASCII.GetBytes(parameters);
                System.IO.Stream os = null;
                req.ContentLength = bytes.Length;
                os = req.GetRequestStream();
                os.Write(bytes, 0, bytes.Length);
                System.Net.WebResponse webResponse = req.GetResponse();
                System.IO.Stream stream = webResponse.GetResponseStream();
                System.IO.StreamReader reader = new System.IO.StreamReader(stream);
                string response = reader.ReadToEnd();
                Newtonsoft.Json.Linq.JObject o = Newtonsoft.Json.Linq.JObject.Parse(response);
                strResult = "SUCCESS:" + o["access_token"].ToString();                    
        }
        catch (Exception ex)
        {
            strResult = "ERROR:" + ex.Message.ToString();
        }
        return strResult;
    }

Refer

Mohan Kumar
  • 647
  • 7
  • 8
  • Upvoted. Pinterest POS API shows the parameters as query params, not form elements, which cost me several hours of hair tearing, until I came across your post. – Abhijit Sarkar Sep 09 '17 at 02:05
0

Pinterest uses the User Flow or Oauth2 When you have an app you ant to use the app flow with an access token

So you need to create the flow yourself or use this tool online https://frederik.today/codehelper/tools/oauth-access-token-pinterest

To make it yourself

  1. Request Token
  2. Exchange code for Acces Token

https://developers.pinterest.com/docs/api/v5/