From e70b59bd2b4e0ca698cfe514bab0856b65d01f9d Mon Sep 17 00:00:00 2001 From: Staffan Eketorp Date: Wed, 22 Nov 2017 11:35:47 +0100 Subject: [PATCH] Allowing setting agent for Oauth (not just Oauth2) --- lib/oauth.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/oauth.js b/lib/oauth.js index 50dccf99..be396ff4 100644 --- a/lib/oauth.js +++ b/lib/oauth.js @@ -37,6 +37,12 @@ exports.OAuth= function(requestUrl, accessUrl, consumerKey, consumerSecret, vers this._oauthParameterSeperator = ","; }; +// Allows you to set an agent to use instead of the default HTTP or +// HTTPS agents. Useful when dealing with your own certificates. +exports.OAuth.prototype.setAgent = function(agent) { + this._agent = agent; +}; + exports.OAuthEcho= function(realm, verify_credentials, consumerKey, consumerSecret, version, signatureMethod, nonceSize, customHeaders) { this._isEcho = true; @@ -247,6 +253,12 @@ exports.OAuth.prototype._createClient= function( port, hostname, method, path, h method: method, headers: headers }; + + //set the agent on the request options + if (this._agent) { + options.agent = this._agent; + } + var httpModel; if( sslEnabled ) { httpModel= https;