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'),
|
||||
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._accessUrl= accessUrl;
|
||||
this._consumerKey= consumerKey;
|
||||
@ -21,6 +21,9 @@ exports.OAuth= function(requestUrl, accessUrl, consumerKey, consumerSecret, vers
|
||||
throw new Error("Un-supported signature method: " + signatureMethod )
|
||||
this._signatureMethod= signatureMethod;
|
||||
this._nonceSize= nonceSize || 32;
|
||||
this._headers= customHeaders || {"Accept" : "*/*",
|
||||
"Connection" : "close",
|
||||
"User-Agent" : "Node authentication"}
|
||||
};
|
||||
|
||||
exports.OAuth.prototype._getTimestamp= function() {
|
||||
@ -207,9 +210,11 @@ exports.OAuth.prototype._performSecureRequest= function( oauth_token, oauth_toke
|
||||
|
||||
headers["Authorization"]= authHeader;
|
||||
headers["Host"] = parsedUrl.host
|
||||
headers["Accept"]= "*/*"
|
||||
headers["Connection"]= "close"
|
||||
headers["User-Agent"]= "Express authentication"
|
||||
|
||||
for( var key in this._headers ) {
|
||||
headers[key]= this._headers[key];
|
||||
}
|
||||
|
||||
headers["Content-length"]= post_body ? post_body.length : 0; //Probably going to fail if not posting ascii
|
||||
headers["Content-Type"]= post_content_type;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user