Saturday 15 July 2017

How do I get an OAuth 1A token from my node app?

I want to use the tumblr api in my node app, and need OAuth 1a to authorize. The official tumblr node library requires an existing Token and Token Secret, so I need to request one. I checked out node-oauth, but it doesn't seem to have any (documented) way to get a new OAuth 1 token. I've spent a few hours trying desperately to figure out how to get a new token for a user.My goal is to retrieve a URL for this sort of page which I can open in the user's browser, which should then send a request to my API callback containing the token, but I'm completely lost. Could somebody point me in the right direction?I've tried this code, which I thought would result in the token being sent to my callback URL, but the logs on the server I set up to receive the callback show absolutely nothing. (And, in retrospect, I completely ignored the fact that the user needs to see an authorization prompt in their browser for this to work.)const oauth = require('oauth') const oa = new oauth.OAuth( 'http://ift.tt/1e3TrA7', 'http://ift.tt/Lohona', '< the consumer key >', '< the consumer secret >', '1.0A', null, 'HMAC-SHA1' ) oa.getOAuthAccessToken('', {'grant_type':'client_credentials'},(e) => {console.log(e)})

Submitted July 16, 2017 at 06:33AM by _tague

No comments:

Post a Comment