Permalink
Browse files

Added optional (1.0A) oauth_verifier parameter to getOauthAccessToken

Stopped non oauth_xxxx parameters being added to the OAuth Authorization headers.
  • Loading branch information...
1 parent 24bcc8c commit c997795239eb321fd65c0da9486e52a75fcf56bb @ciaranj committed May 10, 2010
Showing with 12 additions and 4 deletions.
  1. +12 −4 lib/oauth.js
View
@@ -192,8 +192,9 @@ exports.OAuth.prototype._performSecureRequest= function( oauth_token, oauth_toke
var headers= {}
// build request authorization header
- var authHeader="OAuth ";
+ var authHeader="OAuth ";
for( var i= 0 ; i < orderedParameters.length; i++) {
+ if( orderedParameters[i][0].substring(0,5) == "oauth" )
authHeader+= this._encodeData(orderedParameters[i][0])+"=\""+ this._encodeData(orderedParameters[i][1])+"\",";
}
authHeader= authHeader.substring(0, authHeader.length-1);
@@ -211,7 +212,7 @@ exports.OAuth.prototype._performSecureRequest= function( oauth_token, oauth_toke
else path= parsedUrl.pathname;
var request = oauthProvider.request(method, path , headers);
- var data="";
+ var data="";
var self= this;
request.addListener('response', function (response) {
response.setEncoding('utf8');
@@ -230,8 +231,15 @@ 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 && callback) { // 1.0A
+ extraParams["oauth_verifier"]= oauth_verifier;
+ } else {
+ callback= 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 );

0 comments on commit c997795

Please sign in to comment.