ciaranj / node-oauth

OAuth wrapper for node.js
MIT License
2.44k stars 662 forks source link

add a proxy usage #358

Open AlanGuo opened 3 years ago

AlanGuo commented 3 years ago

Hi! πŸ‘‹

Firstly, thanks for your work on this project! πŸ™‚

Today I used patch-package to patch oauth@0.9.15 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/oauth/lib/oauth.js b/node_modules/oauth/lib/oauth.js
index 50dccf9..819e689 100644
--- a/node_modules/oauth/lib/oauth.js
+++ b/node_modules/oauth/lib/oauth.js
@@ -247,6 +247,12 @@ exports.OAuth.prototype._createClient= function( port, hostname, method, path, h
     method: method,
     headers: headers
   };
+  //  for proxy for local 
+  const HttpsProxyAgent = require('https-proxy-agent');
+  const proxy = process.env.http_proxy;
+  const agent = new HttpsProxyAgent(proxy);
+  options.agent = agent;
+
   var httpModel;
   if( sslEnabled ) {
     httpModel= https;

This issue body was partially generated by patch-package.