Add support for specifying whatever static HTTP headers one wishes with the OAuth requests
This commit is contained in:
parent
752c4419f9
commit
24c91e02b9
13
lib/oauth.js
13
lib/oauth.js
@ -4,7 +4,7 @@ var crypto= require('crypto'),
|
|||||||
URL= require('url'),
|
URL= require('url'),
|
||||||
querystring= require('querystring');
|
querystring= require('querystring');
|
||||||
|
|
||||||
exports.OAuth= function(requestUrl, accessUrl, consumerKey, consumerSecret, version, authorize_callback, signatureMethod, nonceSize) {
|
exports.OAuth= function(requestUrl, accessUrl, consumerKey, consumerSecret, version, authorize_callback, signatureMethod, nonceSize, customHeaders) {
|
||||||
this._requestUrl= requestUrl;
|
this._requestUrl= requestUrl;
|
||||||
this._accessUrl= accessUrl;
|
this._accessUrl= accessUrl;
|
||||||
this._consumerKey= consumerKey;
|
this._consumerKey= consumerKey;
|
||||||
@ -21,6 +21,9 @@ exports.OAuth= function(requestUrl, accessUrl, consumerKey, consumerSecret, vers
|
|||||||
throw new Error("Un-supported signature method: " + signatureMethod )
|
throw new Error("Un-supported signature method: " + signatureMethod )
|
||||||
this._signatureMethod= signatureMethod;
|
this._signatureMethod= signatureMethod;
|
||||||
this._nonceSize= nonceSize || 32;
|
this._nonceSize= nonceSize || 32;
|
||||||
|
this._headers= customHeaders || {"Accept" : "*/*",
|
||||||
|
"Connection" : "close",
|
||||||
|
"User-Agent" : "Node authentication"}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.OAuth.prototype._getTimestamp= function() {
|
exports.OAuth.prototype._getTimestamp= function() {
|
||||||
@ -207,9 +210,11 @@ exports.OAuth.prototype._performSecureRequest= function( oauth_token, oauth_toke
|
|||||||
|
|
||||||
headers["Authorization"]= authHeader;
|
headers["Authorization"]= authHeader;
|
||||||
headers["Host"] = parsedUrl.host
|
headers["Host"] = parsedUrl.host
|
||||||
headers["Accept"]= "*/*"
|
|
||||||
headers["Connection"]= "close"
|
for( var key in this._headers ) {
|
||||||
headers["User-Agent"]= "Express authentication"
|
headers[key]= this._headers[key];
|
||||||
|
}
|
||||||
|
|
||||||
headers["Content-length"]= post_body ? post_body.length : 0; //Probably going to fail if not posting ascii
|
headers["Content-length"]= post_body ? post_body.length : 0; //Probably going to fail if not posting ascii
|
||||||
headers["Content-Type"]= post_content_type;
|
headers["Content-Type"]= post_content_type;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user