Possible mechanism for returning a signed request object.
if oauth.get/post is called without a callback parameter it will return a valid request object that can have custom listeners etc. attached to it. Don't forget to call 'end' on it :)
This commit is contained in:
parent
b79bce508f
commit
3b94a77e5c
11
lib/oauth.js
11
lib/oauth.js
@ -224,6 +224,7 @@ exports.OAuth.prototype._performSecureRequest= function( oauth_token, oauth_toke
|
|||||||
else path= parsedUrl.pathname;
|
else path= parsedUrl.pathname;
|
||||||
|
|
||||||
var request = oauthProvider.request(method, path , headers);
|
var request = oauthProvider.request(method, path , headers);
|
||||||
|
if( callback ) {
|
||||||
var data="";
|
var data="";
|
||||||
var self= this;
|
var self= this;
|
||||||
request.addListener('response', function (response) {
|
request.addListener('response', function (response) {
|
||||||
@ -246,6 +247,12 @@ exports.OAuth.prototype._performSecureRequest= function( oauth_token, oauth_toke
|
|||||||
}
|
}
|
||||||
request.end();
|
request.end();
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
return request;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
exports.OAuth.prototype.getOAuthAccessToken= function(oauth_token, oauth_token_secret, oauth_verifier, callback) {
|
exports.OAuth.prototype.getOAuthAccessToken= function(oauth_token, oauth_token_secret, oauth_verifier, callback) {
|
||||||
var extraParams= {};
|
var extraParams= {};
|
||||||
@ -274,7 +281,7 @@ exports.OAuth.prototype.getProtectedResource= function(url, method, oauth_token,
|
|||||||
}
|
}
|
||||||
|
|
||||||
exports.OAuth.prototype.get= function(url, oauth_token, oauth_token_secret, callback) {
|
exports.OAuth.prototype.get= function(url, oauth_token, oauth_token_secret, callback) {
|
||||||
this._performSecureRequest( oauth_token, oauth_token_secret, "GET", url, null, "", null, callback );
|
return this._performSecureRequest( oauth_token, oauth_token_secret, "GET", url, null, "", null, callback );
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.OAuth.prototype.post= function(url, oauth_token, oauth_token_secret, post_body, post_content_type, callback) {
|
exports.OAuth.prototype.post= function(url, oauth_token, oauth_token_secret, post_body, post_content_type, callback) {
|
||||||
@ -288,7 +295,7 @@ exports.OAuth.prototype.post= function(url, oauth_token, oauth_token_secret, pos
|
|||||||
extra_params= post_body;
|
extra_params= post_body;
|
||||||
post_body= querystring.stringify(post_body);
|
post_body= querystring.stringify(post_body);
|
||||||
}
|
}
|
||||||
this._performSecureRequest( oauth_token, oauth_token_secret, "POST", url, extra_params, post_body, post_content_type, callback );
|
return this._performSecureRequest( oauth_token, oauth_token_secret, "POST", url, extra_params, post_body, post_content_type, callback );
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.OAuth.prototype.getOAuthRequestToken= function(extraParams, callback) {
|
exports.OAuth.prototype.getOAuthRequestToken= function(extraParams, callback) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user