node.js - Refresh Yahoo OAuth 1.0 Access Token Using Passport -
i have express app i'm trying refresh yahoo oauth 1.0 access token before expires after hour user doesn't have re-login. i'm using https-passport-yahoo-oauth passport strategy, works initial oauth.
there's strategy (passport-oauth2-refresh) refreshing oauth 2.0 token here, haven't been able work (obvious reasons, suppose).
yahoo docs on refreshing access token here => https://developer.yahoo.com/oauth/guide/oauth-refreshaccesstoken.html
this code initial oauth below. how can exchange expire or expiring token new 1 based off this?
passport.serializeuser(function(user, done) { done(null, user); }); passport.deserializeuser(function(obj, done) { done(null, obj); }); var strategy = new yahoostrategy({ consumerkey: app_key, consumersecret: app_secret, callbackurl: (process.env.app_url || require('./conf.js').app_url) + 'auth/yahoo/callback' }, function(token, tokensecret, profile, done) { var data = profile._json; var userobj = { id: profile.id, name: data.profile.nickname, avatar: data.profile.image.imageurl, datejoined: new date().gettime(), lastupdated: new date().gettime(), lastvisit: new date().gettime(), accesstoken: token, tokensecret: tokensecret, sessionhandle: profile.oauth_session_handle }; return done(null, userobj); } ); passport.use(strategy);
i thinking might able use request, , roll own token refresh, though i'm little unsure start there. help? appreciate suggestions.
yep, can totally using request:
request.post('https://api.login.yahoo.com/oauth/v2/get_token', { oauth: { consumer_key:'...', consumer_secret:'...', token:'...', token_secret:'...', session_handle:'...' } }, function (err, res, body) {})
alternatively can use purest well. note should store session_handle
when user authorizes app first time.
Comments
Post a Comment