2014-01-30 55 views
9

我正在访问Pinterest API以通过使用此url获取用户信息,但我无法找到如何为Pinterest生成访问令牌。如何获取Pinterest的OAuth访问令牌?

根据这一blog post,它说,

Pinterest的使用的OAuth2认证用户

能否请你告诉我,我从哪里可以生成Pinterest的OAuth访问令牌?

回答

3

您需要注册在下拉菜单下的经理应用程序选项客户端应用程序,当你登录

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

注册您的应用程序,你会得到的AppID。

这遵循这个链接的过程中,你有

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

希望这有助于

+0

你如何获得client_secret?它不会出现在仪表板上。 –

+1

有该网页上的签名测试一种选择,一旦你在里面点击你会看到client_secret –

7

首先,注册一个应用程序,并成立了一个重定向URI:

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

然后,在Signature Tester下找到您的客户秘密:

如果令牌

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

如果响应类型,它将在重定向的URI被附加作为散列:

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

带给用户像这样的OAuth对话框。

如果响应类型是代码,请参阅下面有关如何为辅币代码的详细信息后:

What's the auth code endpoint in Pinterest?

+0

我想用\t https://www.pinterest.com/oauth/请在下面帮 授权是我的链接 https://pinterest.com/oauth/?consumer_id=4944452830850198488&redirect_uri=https%3A%2F%2Ftest.xxxxxx.com%2Fconnectpinterestboardapi&response_type=code&state=121213131312 嗨,大家好我的上述不工作 哪些代码类型链接我们需要额外的吗? 是应用程序ID消费者ID? 没有那么当我得到消费者ID? 和我的消费者ID(应用程序ID)有更多的数字,那么你的 伙计们帮我 –

1
**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

+0

Upvoted。 Pinterest POS API将参数显示为查询参数,而不是表单元素,这会花费我几个小时的头发撕裂,直到我遇到您的帖子。 –

相关问题