OAuth2 Provider Callbacks Do Not Preserve Custom Query Parameters #11607
Unanswered
aryanjangid
asked this question in
Help
Replies: 1 comment
-
You can add addition authorization params via the third argument https://authjs.dev/reference/nextjs#signin-2 or adding them to the provider itself |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Environment
Reproduction URL
https://github.com/dr15/auth-callback
Describe the issue
When initiating the OAuth2 authentication process with a callbackUrl that includes custom query parameters, these parameters are not included in the callbackUrl after the authentication process completes. This behavior is observed when using OAuth2 providers like Google with NextAuth.js.
For example, if the callbackUrl is set to
http://localhost:3000/authorize?org_id=123&redirect_uri=http://localhost:3001/
before initiating the OAuth2 authentication process, the user is redirected to http://localhost:3000/authorize after the authentication process, with the org_id and redirect_uri parameters removed.This issue does not occur when using the Credentials provider. The custom query parameters in the callbackUrl are preserved after the authentication process.
This behavior makes it difficult to maintain application state across the authentication process when using OAuth2 providers. The application state has to be stored in a separate server-side session or a database, which adds complexity to the application.
It would be beneficial if NextAuth.js could preserve the custom query parameters in the callbackUrl across the authentication process when using OAuth2 providers. This would allow developers to maintain application state more easily and make the library more flexible to use.
How to reproduce
Steps to Reproduce:
Expected behavior
After the authentication process, the user should be redirected to the callbackUrl with the custom query parameters preserved, e.g.,
http://localhost:3000/authorize?org_id=123&redirect_uri=http://localhost:3001/
.Actual Behavior:
The user is redirected to the callbackUrl, but the custom query parameters are removed, e.g.,
http://localhost:3000/authorize
.Beta Was this translation helpful? Give feedback.
All reactions