Skip to content
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

Proxy config not working when using oauth 2.0 authentication #383

Open
cvchavez2 opened this issue Apr 3, 2023 · 2 comments
Open

Proxy config not working when using oauth 2.0 authentication #383

cvchavez2 opened this issue Apr 3, 2023 · 2 comments
Labels

Comments

@cvchavez2
Copy link

cvchavez2 commented Apr 3, 2023

Describe the bug?

I'm running behind a proxy.

Using the SDK with an Okta API key works as expected when I provide the httpsProxy config to the client.

Example:

const oktaProvider = require('@okta/okta-sdk-nodejs')

const oktaClient = new oktaProvider.Client({
    orgUrl: 'https://{okta-org}.oktapreview.com/',
    token: process.env.OTOKEN,
    httpsProxy: process.env.HTTPS_PROXY
})

The thing is we don't want to use an API key but rather implement OAuth 2.0 authentication using scoped tokens.

When we configure the Okta client with the values needed we start getting ECONNRESET errors. We then go ahead and set the httpsProxy value as it is referenced here. The same problem occurs then. The difference with that example is that the API key is being used not the private key.

Error example:
FetchError: request to https://{okta-org}.oktapreview.com/oauth2/v1/token failed, reason: read ECONNRESET

Example of client config with private key values:

const oktaClient = new oktaProvider.Client({
    orgUrl: 'https://{okta-org}.oktapreview.com/',
    authorizationMode: 'PrivateKey',
    clientId: '{xxxxxx client id xxxx}',
    scopes: ['okta.users.read'],
    privateKey: privateKey,
    httpsProxy: process.env.HTTPS_PROXY,
    keyId: kid 
})

I have tried passing in the privateKey in the 3 possible ways that it is recommended to ensure I was not getting that part wrong.

I understand that when you use the OAuth 2.0 approach with scoped tokens the sdk makes requests to the /token endpoint. What I don't understand is why the proxy config does not work when you use a private key? Both approaches should be consistent.

What is expected to happen?

Providing the httpsProxy to the client should allow you to connect to Okta if you are behind a proxy using either an API key or OAuth 2.0.

What is the actual behavior?

FetchError: request to https://{okta-org}.oktapreview.com/oauth2/v1/token failed, reason: read ECONNRESET

Reproduction Steps?

You need to be running behind a proxy.

In the description of the bug I provided details on how I came across this problem.

SDK Versions

okta-sdk-nodejs version 6.6.0

Execution Environment

nodejs 19.6.0
macOS

Additional Information?

No response

@cvchavez2 cvchavez2 added the bug label Apr 3, 2023
@denysoblohin-okta
Copy link
Contributor

Thanks for submitting this issue.
Internal ref: OKTA-597488

@b4usat
Copy link

b4usat commented Jul 9, 2023

Any updates to this issue. I have a similar issue with authenticationmode set to PrivateKey, without setting proxy. Not getting response back from okta. V7.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants