next-auth only valid absolute URLs can be requested

6.1k Views Asked by At

I updated [email protected] to [email protected] for okta signin(reactjs). After that I am getting the following errors:

[next-auth][error][SIGNIN_OAUTH_ERROR] https://next-auth.js.org/errors#signin_oauth_error only valid absolute URLs can be requested

Please anyone help me get out of this.

4

There are 4 best solutions below

0
On

Make sure that your okta issuer looks like this:

https://{your_okta_domain}.okta.com/oauth2/default

Also if you are using it in localhost, in your .env file make sure that you store this variable without enclosing it in "". So instead of storing the value as:

OKTA_ISSUER = "my_okta_issuer"

use instead:

OKTA_ISSUER = my_okta_issuer

It took me a day to figure that out, but now it works.

0
On

Most probably you missed a step when upgrading, I suggest you (re-)visit the update guide

The description you provided is very minimal, making it hard to give you a valuable answer. If you share your codebase somehow, either via GitHub, a sandbox, or a minimal reproducible example, the community can help you better

1
On

Another difference... the domain has to include https://

1
On

Make sure that after you upgrade from next-auth v3 to v4, you also update the config object you're passing to OktaProvider.

The problem with me is that I was still using domain while the new API was expecting issuer.

v3:

OktaProvider({
  clientId: data.REACT_APP_OKTA_CLIENTID,
  clientSecret: data.REACT_APP_OKTA_CLIENTSECRET,
  domain: data.REACT_APP_OKTA_DOMAIN, // <<<<<<<<<< before
}),

v4:

OktaProvider({
  clientId: data.REACT_APP_OKTA_CLIENTID,
  clientSecret: data.REACT_APP_OKTA_CLIENTSECRET,
  issuer: data.REACT_APP_OKTA_DOMAIN, // <<<<<<<<<< after
}),