node-oauth icon indicating copy to clipboard operation
node-oauth copied to clipboard

How to set proxy in node-auth

Open byteshiva opened this issue 8 years ago • 2 comments

I would like to add httpsProxyAgent to node-auth. Does the current implementation has option to add agent option to node-oauth.

This is what I would need...

var HttpsProxyAgent = require('https-proxy-agent');
if (process.env['https_proxy']) {
  httpsProxyAgent = new HttpsProxyAgent(process.env['https_proxy']);
}

Finally, set the httpsProxyAgent to the request options right before _executeRequest gets called like this:

options.agent = httpsProxyAgent

byteshiva avatar Jul 13 '16 08:07 byteshiva

I wanted to add proxy details at https://github.com/ciaranj/node-oauth/blob/master/lib/oauth2.js#L110

How can I pass these details. example:

options.proxyhost = 'xyz',
options.proxyport = 1234
options.agent = httpsProxyAgent

byteshiva avatar Jul 14 '16 19:07 byteshiva

How about using setAgent()?

var HttpsProxyAgent = require('https-proxy-agent');
var oauth2 = new OAuth2(...);
if (process.env['https_proxy']) {
  var httpsProxyAgent = new HttpsProxyAgent(process.env['https_proxy']);
  oauth2.setAgent(httpsProxyAgent);
}

iwaiktos avatar Feb 13 '17 05:02 iwaiktos