Troubleshooting fetchAccessToken for Tumblr

70 views
Skip to first unread message

Constance Brown

unread,
Oct 14, 2012, 4:58:20 PM10/14/12
to jso...@googlegroups.com
I'm trying to gain access to Tumblr's API via jsoauth. I successfully managed to get to run through all the steps entailed in the fetchRequestToken function, however I'm having trouble with fetchAccessToken. Chrome's log gave me the following error:

Failed to load resource: the server responded with a status of 400 (Bad Request) http://www.tumblr.com/oauth/access_token
Object
requestHeaders: Object
responseHeaders: Object
text: "Missing or invalid oauth_verifier."
xml: ""
__proto__: Object
 background.js:29
failureHandler

This is the code that's running:
    var oauth, options;

    options = {
        consumerKey: 'MYKEY',
        consumerSecret: 'MYSECRET',
    };

    oauth = OAuth(options);
oauth.fetchRequestToken(openAuthoriseWindow, failureHandler);
function openAuthoriseWindow(url)
{
var wnd = window.open(url, 'authorise');
oauth.fetchAccessToken(printKeys,failureHandler);
function printKeys(){
 console.log(options.accessTokenKey);
 console.log(options.accessTokenSecret);
}
}
  
function failureHandler(data)
{
console.error(data);
}

It's obviously something I'm doing wrong, but I'm not sure what. Not of the functions are particularly complicated since I'm just trying to get everything to work before adding in conditions. Have I executed something in the wrong order or missed a step?

Constance Brown

unread,
Oct 15, 2012, 7:27:33 PM10/15/12
to jso...@googlegroups.com
I solved the problem. It turns out that for tumblr you have to set the verifier to false.

Rob Griffiths

unread,
Oct 16, 2012, 7:42:30 AM10/16/12
to jso...@googlegroups.com
Sorry I haven't responded before now, I'm pleased you found a solution.
Does strike me as odd that they would require a false verifier.


-- 
Rob Griffiths
Sent with Sparrow

Constance Brown

unread,
Oct 16, 2012, 2:30:56 PM10/16/12
to jso...@googlegroups.com
I know, it's very weird. I saw a php oauth implementation for communicating with tumblr and the verifier was set to false. I tried it and boom, I could take with tumblr. They should really mention that in their oAuth section because I don't think that missing verifiers are a thing that most people would think to check for.

I do have a request. Would you have a look at another problem I'm having right now. You can see it here. For some reason, I can't authenticate. I don't think it has to do with the library in particular, but your insight about oauth would provide an experienced eye and be much appreciated.

Rob Griffiths

unread,
Oct 16, 2012, 3:51:38 PM10/16/12
to jso...@googlegroups.com
See my response on the SO question

If you need my code let me know.


-- 
Rob Griffiths
Sent with Sparrow

Constance Brown

unread,
Oct 18, 2012, 10:53:21 AM10/18/12
to jso...@googlegroups.com
Based on your commentary, it seems the problem is that I'm not capturing the URL change after the user clicks allow or deny. Do you have any ideas how I can capture that?

As best I can tell the allow/deny page is dynamically generated. During the onload event there's nothing but an empty body tag, so there's nothing to set event listeners to.

Rob Griffiths

unread,
Oct 18, 2012, 11:01:03 AM10/18/12
to jso...@googlegroups.com
Could you attach a onload handler to the window?

It looks like you're writing a chrome extension so maybe something with Content Scripts is possible? https://developer.chrome.com/extensions/content_scripts.html



-- 
Rob Griffiths
Sent with Sparrow

Constance Brown

unread,
Oct 19, 2012, 11:40:15 AM10/19/12
to jso...@googlegroups.com
Okay, I figured why i couldn't capture the verifier, the callback URL I assigned kept striping the query string. Once I assigned a different callback url I should see the verifier. Thank you for all your help!
Reply all
Reply to author
Forward
0 new messages