From c8393eb053e1e61911cd52a8d36e50bfae1b83e0 Mon Sep 17 00:00:00 2001 From: Mark Wubben Date: Wed, 28 Jul 2010 19:24:13 +0200 Subject: [PATCH] Support for passing extra parameters when getting a request token. Changed `getOAuthAccessToken` to always expect an `oauth_verifier` value (although it could be `null`). --- lib/oauth.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/oauth.js b/lib/oauth.js index 16e5e47..c494fe3 100644 --- a/lib/oauth.js +++ b/lib/oauth.js @@ -233,8 +233,12 @@ exports.OAuth.prototype._performSecureRequest= function( oauth_token, oauth_toke request.end(); } -exports.OAuth.prototype.getOAuthAccessToken= function(oauth_token, oauth_token_secret, callback) { - this._performSecureRequest( oauth_token, oauth_token_secret, "GET", this._accessUrl, null, function(error, data, response) { +exports.OAuth.prototype.getOAuthAccessToken= function(oauth_token, oauth_token_secret, oauth_verifier, callback) { + var extraParams = {}; + if( oauth_verifier ) { + extraParams.oauth_verifier = oauth_verifier; + } + this._performSecureRequest( oauth_token, oauth_token_secret, "GET", this._accessUrl, extraParams, function(error, data, response) { if( error ) callback(error); else { var results= querystring.parse( data ); @@ -250,8 +254,12 @@ exports.OAuth.prototype.getProtectedResource= function(url, method, oauth_token, this._performSecureRequest( oauth_token, oauth_token_secret, method, url, null, callback ); } -exports.OAuth.prototype.getOAuthRequestToken= function(callback) { - var extraParams= {}; +exports.OAuth.prototype.getOAuthRequestToken= function(extraParams, callback) { + if( typeof extraParams == "function" ){ + callback = extraParams; + extraParams = {}; + } + // Callbacks are 1.0A related if( this._authorize_callback ) { extraParams["oauth_callback"]= this._authorize_callback;