【问题标题】:401 error when authenticating with tumblr using jsoauth javascript oauth library使用 jsoauth javascript oauth 库对 tumblr 进行身份验证时出现 401 错误
【发布时间】:2012-10-06 02:16:16
【问题描述】:

我正在为 tumblr 构建一个 chrome 扩展。我正在使用库 jsoauth 执行 oauth 部分,但出现 401 错误。

确切的错误是“oauth_signature [D6rDCSn/ClGhMyTq24/c6419t8I=] 与预期值 [wnrVNhZYCSfRmKSTaKyb9dg7vNQ=] 不匹配”

我不知道是什么原因造成的。这是我的代码:

背景.html

<html>
    <script type="text/javascript" src="jsOAuth-1.3.6.min.js"></script>
    <script type="text/javascript" src="background.js"></script>
</html>

background.js

function getAccess(){
  var oauth, options;

    options = {
        consumerKey: 'KEY',
        consumerSecret: 'SECRET',
        requestTokenUrl: "http://www.tumblr.com/oauth/request_token",
        authorizationUrl: "http://www.tumblr.com/oauth/authorize",
        accessTokenUrl: "http://www.tumblr.com/oauth/access_token"
    };

    oauth = OAuth(options);

    oauth.fetchRequestToken(openAuthoriseWindow, failureHandler);

    function openAuthoriseWindow(url)
    {
        var wnd = window.open(url, 'authorise');
        oauth.setVerifier(false);
        oauth.fetchAccessToken(output,failureHandler);

        function output(url)
        {
            console.log("success!");
        }
    }

    function failureHandler(data)
    {
        console.error(data);
    }
}

chrome.extension.onMessage.addListener(
  function(request, sender, sendResponse) {
    if (request.greeting == "getAccess"){
      sendResponse({farewell: "It worked"});
      getAccess();
    }
});

【问题讨论】:

    标签: javascript oauth google-chrome-extension tumblr jsoauth


    【解决方案1】:

    False 作为 oauth_verifier 发送是错误的。

    Tumblr 会将您重定向到他们存档的 oauth_callback,其中包括您需要在 jsOAuth 中探查到 .setVerifier 的 oauth_verifier。

    Tumblr API 文档在解释 ouath 授权过程方面非常失误,但这是我的看法。

    【讨论】:

      猜你喜欢
      • 2012-04-24
      • 1970-01-01
      • 1970-01-01
      • 2011-02-06
      • 2015-11-28
      • 2019-09-30
      • 2016-03-22
      • 2022-12-03
      • 2015-05-05
      相关资源
      最近更新 更多