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?

4 Answers 4

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?

1
  • I want to authorize using pinterest.com/oauth please help below is my link pinterest.com/oauth/… 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 Commented Jan 24, 2018 at 6: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

2
  • How do you obtain the client_secret? It doesn't appear on the dashboard. Commented May 15, 2014 at 1:11
  • 1
    there is an option for Signature Tester on that page, once you click in there you will see the client_secret Commented Jun 12, 2014 at 15:00
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

1
  • 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. Commented Sep 9, 2017 at 2: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/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.