Added support for GET when requesting request tokens
This commit is contained in:
parent
a2ac03bc37
commit
1b4624cacd
@ -460,16 +460,21 @@ exports.OAuth.prototype.post= function(url, oauth_token, oauth_token_secret, pos
|
|||||||
}
|
}
|
||||||
|
|
||||||
exports.OAuth.prototype.getOAuthRequestToken= function(extraParams, callback) {
|
exports.OAuth.prototype.getOAuthRequestToken= function(extraParams, callback) {
|
||||||
|
var httpMethod;
|
||||||
if( typeof extraParams == "function" ){
|
if( typeof extraParams == "function" ){
|
||||||
callback = extraParams;
|
callback = extraParams;
|
||||||
extraParams = {};
|
extraParams = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( typeof callback == "string"){
|
||||||
|
httpMethod = callback;
|
||||||
|
}
|
||||||
|
|
||||||
// Callbacks are 1.0A related
|
// Callbacks are 1.0A related
|
||||||
if( this._authorize_callback ) {
|
if( this._authorize_callback ) {
|
||||||
extraParams["oauth_callback"]= this._authorize_callback;
|
extraParams["oauth_callback"]= this._authorize_callback;
|
||||||
}
|
}
|
||||||
this._performSecureRequest( null, null, "POST", this._requestUrl, extraParams, null, null, function(error, data, response) {
|
this._performSecureRequest( null, null, httpMethod || "POST", this._requestUrl, extraParams, null, null, function(error, data, response) {
|
||||||
if( error ) callback(error);
|
if( error ) callback(error);
|
||||||
else {
|
else {
|
||||||
var results= querystring.parse(data);
|
var results= querystring.parse(data);
|
||||||
|
@ -133,6 +133,19 @@ vows.describe('OAuth').addBatch({
|
|||||||
assert.equal( oa.signUrl("http://somehost.com:3323/foo/poop?bar=foo", "token", "tokensecret"), "http://somehost.com:3323/foo/poop?bar=foo&oauth_consumer_key=consumerkey&oauth_nonce=ybHPeOEkAUJ3k2wJT9Xb43MjtSgTvKqp&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1272399856&oauth_token=token&oauth_version=1.0&oauth_signature=zeOR0Wsm6EG6XSg0Vw%2FsbpoSib8%3D");
|
assert.equal( oa.signUrl("http://somehost.com:3323/foo/poop?bar=foo", "token", "tokensecret"), "http://somehost.com:3323/foo/poop?bar=foo&oauth_consumer_key=consumerkey&oauth_nonce=ybHPeOEkAUJ3k2wJT9Xb43MjtSgTvKqp&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1272399856&oauth_token=token&oauth_version=1.0&oauth_signature=zeOR0Wsm6EG6XSg0Vw%2FsbpoSib8%3D");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
'When getting a request token': {
|
||||||
|
topic: function() {
|
||||||
|
var oa= new OAuth(null, null, "consumerkey", "consumersecret", "1.0", null, "HMAC-SHA1");
|
||||||
|
oa._getTimestamp= function(){ return "1272399856"; }
|
||||||
|
oa._getNonce= function(){ return "ybHPeOEkAUJ3k2wJT9Xb43MjtSgTvKqp"; }
|
||||||
|
oa._performSecureRequest= function(){ return this.requestArguments = arguments; }
|
||||||
|
return oa;
|
||||||
|
},
|
||||||
|
'Use the provided HTTP method': function(oa) {
|
||||||
|
oa.getOAuthRequestToken(function() {}, "GET");
|
||||||
|
assert.equal(oa.requestArguments[2], "GET");
|
||||||
|
}
|
||||||
|
},
|
||||||
'When get authorization header' : {
|
'When get authorization header' : {
|
||||||
topic: function() {
|
topic: function() {
|
||||||
var oa= new OAuth(null, null, "consumerkey", "consumersecret", "1.0", null, "HMAC-SHA1");
|
var oa= new OAuth(null, null, "consumerkey", "consumersecret", "1.0", null, "HMAC-SHA1");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user