-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
State cookie / PKCE code_verifier cookie missing #12833
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
Comments
I also faced this using the Github Provider. I somehow fixed it. I deleted parts and started adding parts back in until the issue started to appear. It was caused due to parsing problem. I sent some mismatched data. I just had to handle that and its working again. I would recommend you do the same while keeping this in mind. Best of luck and let me know if it helped. |
Hello, thank you for your reply. Could I have more details on your parsing error? |
I have the same problem. The error I see in logs is "InvalidCheck: state value could not be parsed. Read more at https://errors.authjs.dev#invalidcheck". Upon inspection, found out that the signIn() method we are calling on nextjs middleware on the server, returns a 307 to redirect to the issuer to authorise. But the set-cookie does not seem correct, it seems to have merged callback-url and state cookies into one in production, separated by comma, but instead locally I see two separate set-cookie response headers. This means that the state is not stored in browser and the authorisation eventually fails. This works beautifully locally (even when we are using https). We have spent innumerable number of hours findings why that might be happening, but no clue. We are deploying using opennext to AWS Cloudfront and lambda serverless. Any help is appreciated. |
@ankur-jain-nhs I added the |
Environment
Reproduction URL
https://github.com/LoickNosal/Cookie-Missing-NextAuth
Describe the issue
Hello, I'm having a problem with NextAuth.
I use two providers: Google and Apple.
I have one problem for each provider:
[next-auth][error][OAUTH_CALLBACK_ERROR]
State cookie was missing
providerId: 'google',
message: 'State cookie was missing.'
[next-auth][error][OAUTH_CALLBACK_ERROR]
PKCE code_verifier cookie was missing.
providerId: 'apple',
message: 'PKCE code_verifier cookie was missing.'
These messages appear each time I log in to my application. It's not blocking, and users are able to log in. I'd like to understand the cause because I've already added a PKCE cookie to my next-auth.ts file.
This is polluting my environment's logs, and I'd like to fix it as soon as possible.
My next-auth.ts and next-auth.d.ts files in the link
Here are the versions used:
"next": "^14.2.20",
"next-auth": "^4.24.11",
"react": "18.2.0",
The text was updated successfully, but these errors were encountered: