0

I'm building a chrome extension for tumblr. I'm doing the oauth part using the library jsoauth, but I'm getting a 401 error.

The exact error being, "oauth_signature [D6rDCSn/ClGhMyTq24/c6419t8I=] does not match expected value [wnrVNhZYCSfRmKSTaKyb9dg7vNQ=]"

I have no idea what's causing it. Here's the code I have:

Background.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();
    }
});
Iteria
  • 421
  • 1
  • 5
  • 13

1 Answers1

1

False is the wrong thing to be sending as the oauth_verifier.

Tumblr redirects you to the oauth_callback they have on file, which includes the oauth_verifier you need to plumb into .setVerifier in jsOAuth.

Tumblr API docs are very lapse in explaining much about the ouath authorization process, but thats my opinion.

bytespider
  • 586
  • 5
  • 6