-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option to define a proxy in the configuration or via environment variables #50
Comments
@janb87 thanks for the post. I couldn't get this to work with the recent Okta SDK, node v 12.2 on Windows, with the Fiddler proxy, etc. Does this still work for you? (I know you posted this over a year ago, perhaps things have changed since then) Thanks! |
it's 1 year later and i'm looking for the same solution again. but this time, i got it to work: /*
set https_proxy=http://127.0.0.1:8888
set NODE_TLS_REJECT_UNAUTHORIZED=0
*/
const okta = require('@okta/okta-sdk-nodejs');
const Http = require('@okta/okta-sdk-nodejs/src/http');
const HttpsProxyAgent = require('https-proxy-agent');
class HttpWithProxy extends Http {
constructor({cacheStore, cacheMiddleware, defaultHeaders}) {
super({
cacheStore,
cacheMiddleware,
requestExecutor: new okta.RequestExecutor()
});
this.defaultHeaders = defaultHeaders;
// Okta is only https
const proxy = process.env.https_proxy || process.env.HTTPS_PROXY;
if (proxy) {
const agent = new HttpsProxyAgent(proxy);
this.agent = agent;
}
}
http(uri, request, context) {
if (this.agent) {
request.agent = this.agent;
}
return super.http(uri, request, context);
}
}
const client = new okta.Client({
orgUrl: 'https://XXX.okta.com/',
token: 'XXX'
});
client.http = new HttpWithProxy({
defaultHeaders: client.http.defaultHeaders
});
(async function () {
try {
const user = await client.getUser('me');
console.log(user);
} catch (e) {
console.log(e);
}
})(); |
Internal ref: OKTA-419414 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In our setup we needed to communicate with the okta services via a proxy. To achieve this we had to overwrite the Http implementation.
This is how we solved it:
Could we extend the Client class to take in proxy configuration?
The text was updated successfully, but these errors were encountered: