Next-auth: Site cannot be reached using Okta

Created on 29 Jun 2020  路  3Comments  路  Source: nextauthjs/next-auth

I have read

Your question
How do I properly configure next-auth to use my Okta authorization server?

What are you trying to do
I have an Okta authorization server at https://dev-726851.okta.com/oauth2/default
where "default" is the name of my authorization server as found in my Okta console at API => Authorization Servers
I have configured the next-auth-example project to use only Okta - see config below.

When clicking the "Sign in with Okta" button in my running instance of next-auth-example I get "Site cannot be reached" from the browser. The URL is not what I was expecting (although I may be using next-auth with improper assumptions). The address in the browser at the time of failure is
https://https//dev-726851.okta.com/oauth2/v1/authorize/?response_type=code...
I expected the address to be...
https://dev-726851.okta.com/oauth2/default/v1/authorize?response_type=code...
The difference being the name of my authorization server ("default") between "oauth2" and "v1". I don't see a configuration option to provide the "name" of my authorization server, and the config object is hard-coded to assume the remainder of the path beyond the domain.

Config in my .env is...

SITE=http://localhost:3000
SECRET=[redacted]
OKTA_CLIENT_ID=[redacted]
OKTA_CLIENT_SECRET=[redacted]
OKTA_DOMAIN=https://dev-726851.okta.com

My [...nextauth].js providers section has exactly (and only) what's found in the example Okta provider documentation. I am not using a database, with jwt set to true. No other config changes to the next-auth-example.

Documentation feedback

  • [*] Found the documentation helpful
  • [ ] Found documentation but was incomplete
  • [ ] Could not find relevant documentation
  • [*] Found the example project helpful
  • [ ] Did not find the example project helpful
question

All 3 comments

Hi there!

I think OKTA_DOMAIN should be without the protocol:

e.g.

OKTA_DOMAIN=dev-726851.okta.com

Removing the protocol from Okta domain fixed it. thanks. sorry.
I then had to whitelist the proper redirect URI - but that was unrelated.
I'm curious why the paths differ (and both work) but that's a question for Okta.

@eatrocks Thanks for the feedback. IInterested in any tips you have for using NextAuth.js with Okta!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bscaspar picture bscaspar  路  3Comments

dmi3y picture dmi3y  路  3Comments

SharadKumar picture SharadKumar  路  3Comments

ryanbahan picture ryanbahan  路  3Comments

iaincollins picture iaincollins  路  3Comments