Adding ability to specify an agent for OAuth2 requests
This commit is contained in:
committed by
Philip Skinner
parent
ec6a1b2eaf
commit
6baf574f87
@ -15,7 +15,16 @@ exports.OAuth2= function(clientId, clientSecret, baseSite, authorizePath, access
|
||||
this._authMethod= "Bearer";
|
||||
this._customHeaders = customHeaders || {};
|
||||
this._useAuthorizationHeaderForGET= false;
|
||||
}
|
||||
|
||||
//our agent
|
||||
this._agent = undefined;
|
||||
};
|
||||
|
||||
// Allows you to set an agent to use instead of the default HTTP or
|
||||
// HTTPS agents. Useful when dealing with your own certificates.
|
||||
exports.OAuth2.prototype.setAgent = function(agent) {
|
||||
this._agent = agent;
|
||||
};
|
||||
|
||||
// This 'hack' method is required for sites that don't use
|
||||
// 'access_token' as the name of the access token (for requests).
|
||||
@ -129,6 +138,11 @@ exports.OAuth2.prototype._executeRequest= function( http_library, options, post_
|
||||
|
||||
var result= "";
|
||||
|
||||
//set the agent on the request options
|
||||
if (this._agent) {
|
||||
options.agent = this._agent;
|
||||
}
|
||||
|
||||
var request = http_library.request(options);
|
||||
request.on('response', function (response) {
|
||||
response.on("data", function (chunk) {
|
||||
|
Reference in New Issue
Block a user