From 8e890b6aa3aa501cee42743cf199a9fa4edd17da Mon Sep 17 00:00:00 2001 From: "Edward J. Jinotti" Date: Sat, 30 Apr 2016 09:32:57 -0400 Subject: [PATCH] Allow use of realm in non-echo 1.0 requests. --- lib/oauth.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/oauth.js b/lib/oauth.js index 50dccf99..bf08561d 100644 --- a/lib/oauth.js +++ b/lib/oauth.js @@ -6,7 +6,7 @@ var crypto= require('crypto'), querystring= require('querystring'), OAuthUtils= require('./_utils'); -exports.OAuth= function(requestUrl, accessUrl, consumerKey, consumerSecret, version, authorize_callback, signatureMethod, nonceSize, customHeaders) { +exports.OAuth= function(requestUrl, accessUrl, consumerKey, consumerSecret, version, authorize_callback, signatureMethod, nonceSize, customHeaders, realm) { this._isEcho = false; this._requestUrl= requestUrl; @@ -31,6 +31,9 @@ exports.OAuth= function(requestUrl, accessUrl, consumerKey, consumerSecret, vers this._headers= customHeaders || {"Accept" : "*/*", "Connection" : "close", "User-Agent" : "Node authentication"} + + this._realm = realm; + this._clientOptions= this._defaultClientOptions= {"requestTokenHttpMethod": "POST", "accessTokenHttpMethod": "POST", "followRedirects": true}; @@ -119,7 +122,7 @@ exports.OAuth.prototype._isParameterNameAnOAuthParameter= function(parameter) { // build the OAuth request authorization header exports.OAuth.prototype._buildAuthorizationHeaders= function(orderedParameters) { var authHeader="OAuth "; - if( this._isEcho ) { + if( this._isEcho || this._realm ) { authHeader += 'realm="' + this._realm + '",'; }