【问题标题】:How to Get OAuth Access Token for Pinterest?如何获取 Pinterest 的 OAuth 访问令牌?
【发布时间】:2016-07-20 15:00:10
【问题描述】:

我正在访问 Pinterest API 以使用此 url 获取用户信息,但我找不到如何为 Pinterest 生成访问令牌。

根据这个blog post,它说

Pinterest 使用 OAuth2 对用户进行身份验证

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

【问题讨论】:

    标签: pinterest


    【解决方案1】:

    首先,注册一个应用并设置一个重定向URI:

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

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

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

    像这样将用户带到 OAuth 对话框:

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

    如果响应类型为令牌,它将作为哈希附加在重定向 URI 中。

    如果响应类型是代码,请参阅下面的帖子了解如何将代码交换为令牌:

    What's the auth code endpoint in Pinterest?

    【讨论】:

    • 我想使用pinterest.com/oauth 进行授权,请帮助下面是我的链接pinterest.com/oauth/… 嗨,伙计们,我上面的链接不起作用 我们需要额外执行哪种类型的代码? app id 是消费者 id 吗?没有,那么当我获得消费者 ID 时?我的消费者 ID(应用 ID)比你的数字多 伙计们帮助我
    【解决方案2】:

    您需要在登录时在下拉菜单的管理器应用选项下注册一个客户端应用

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

    注册您的应用,您将获得 AppID。

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

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

    希望对你有帮助

    【讨论】:

    • 如何获取client_secret?它不会出现在仪表板上。
    • 在那个页面上有一个签名测试器的选项,一旦你点击那里你会看到client_secret
    【解决方案3】:
    **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

    【讨论】:

    • 赞成。 Pinterest POS API 将参数显示为查询参数,而不是表单元素,这花了我几个小时的时间,直到我看到你的帖子。
    猜你喜欢
    • 1970-01-01
    • 2015-12-05
    • 2018-02-17
    • 2012-08-03
    • 1970-01-01
    • 1970-01-01
    • 2013-04-09
    • 2011-08-21
    • 2013-05-27
    相关资源
    最近更新 更多