Closed liadyacobi closed 1 year ago
Thank you for your contribution. The PR looks great.
Since this issue has resurfaced, I have taken the time to look more broadly at the way that this package deals with the various different OAuth2 configurations that are in the wild. In the past, there have been a few other issues (#3, #10) raised that also require customisation of the OAuth2 config.
In light of these, a more general approach has been introduced with v2.1.0. A new callback setRefreshOAuth2
can now be supplied to customise the OAuth2 adapter that is used to refresh the token. For this particular use case (setting a proxy agent), you should be able to do the following:
const refresh = require('passport-oauth2-refresh');
const HttpsProxyAgent = require('https-proxy-agent');
// ...
refresh.use(strategy, {
setRefreshOAuth2({ refreshOAuth2 }) {
refreshOAuth2.setAgent(new HttpsProxyAgent(agentUrl));
return refreshOAuth2;
}
});
Please give it a try, and let me know how you get on.
Closing due to inactivity.
Resolves #9 The "use" function now receives a third "agent" parameter which should be the type of HttpsProxyAgent. Added a switch case to handle the case where two parameters (strategy, agent) are sent (without the name param). After the initialization of the current strategy, checks if there is an existing agent, and if there is, it sets it as the agent for the OAuth2 instance.