Replies: 18 comments 41 replies
-
I am also facing this problem, I already check my scopes and it's ok too. I'm also using Google and I noticed that in the first auth, when Google ask me for my credentials is when its happening, but if I sign out and sign in again, Google doesn't ask me because I already authenticated to it before, so the problem doesn't occur |
Beta Was this translation helpful? Give feedback.
-
Ditto. I've been running next-auth@4.0.0-beta.3 for months now and I had my Cognito setup all working. Today I decided to upgrade to 4.0.6 and I'm getting the same errors as the individuals above. ^^ Maybe a diff between 4.0.6 and the 4.0.0-beta.3 may pin point the issue. |
Beta Was this translation helpful? Give feedback.
-
I too am seeing this issue with Cognito. I've rolled back to 4.0.0-beta.3 for now as the latest functional build. 4.0.0-beta-4 introduces an update to the 'openid-client' package from ^4.7.4 to ^5.0.1 (although beta-4 is broken and fixed in beta-5) and now ^5.1.0. It seems openid-client 5.0.1 forced id token validation (client.callback() instead of client.oauthCallback()) and the nonce check in openid-client. You can trigger the same validation by setting idToken true in your next-auth config for Cognito on 4.0.0-beta.3 (becoming the default from beta-5.
Cognito seems to generate the nonce for the initial auth when using an IDP which triggers the error on callback. Beyond that, I'm stumped! |
Beta Was this translation helpful? Give feedback.
-
I'm getting exactly the same error message in my project which uses openid-client in a Remix app. What I can't tell is if this is a bug in Cognito or a bug in openid-client. |
Beta Was this translation helpful? Give feedback.
-
Aha! I figured out a workaround for my code, which may work for next-auth too. Unfortunately my code isn't public (yet) so I can only provide a snippet here. In the call to const tokenSet = await client.callback(getRedirectUri(request), params, {
code_verifier,
nonce: null // <-- add this
}) |
Beta Was this translation helpful? Give feedback.
-
Having the exact same issue as everyone here, errors out on first attempt at login, then works the second time. I'm new to Next-auth, really want to like it but this isn't a great first impression! |
Beta Was this translation helpful? Give feedback.
-
Thanks for the effort @james-bjss . We are also affected by this issue, I'll try your forked version to see if it addresses the issue. I'm mostly posting to add more interest on this fix being merged 😃 |
Beta Was this translation helpful? Give feedback.
-
@lluia @balazsorban44 Can you help us ? PR is here : #4100 |
Beta Was this translation helpful? Give feedback.
-
Created a patch for version 4.10.3 if it's of help to anyone next-auth+4.10.3.patch. |
Beta Was this translation helpful? Give feedback.
-
I have the latest package with this fix in it at Correct me if I'm wrong but I believe you also need to add this to your provider config? checks: 'nonce', |
Beta Was this translation helpful? Give feedback.
-
Hi @james-bjss I am using the latest version 4.10.3 but it is not working. Do I need to perform some extra steps to apply this fix? |
Beta Was this translation helpful? Give feedback.
-
Ah ok noted that!
Thank you very much for the info, I will use the patch for now.
Cheers,
Ronaldwh
…On Sat, Sep 10, 2022, 6:17 PM James ***@***.***> wrote:
Hi @james-bjss <https://github.com/james-bjss>
I am using the latest version 4.10.3 but it is not working. Do I need to
perform some extra steps to apply this fix?
The fix has veen merged to main but there has been no new release since.
You would need to apply the patch package as per convos above until the
next nextauth release with the fix in it.
There is a flurry of chore activity on main at the mo from the maintainers
and looks like they may be prepping for a new release, so if you can wait
the new package should be out eventually.
—
Reply to this email directly, view it on GitHub
<#3551 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFS4MIILFSVIIRBZWRRZ5FDV5RN3FANCNFSM5LGUO74A>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
I'm running the same behavior with: "next": "^13.0.5",
"next-auth": "^4.17.0", MyProvider: import NextAuth from "next-auth";
import CognitoProvider from "next-auth/providers/cognito";
export default NextAuth({
providers: [
// https://github.com/nextauthjs/next-auth/discussions/3551
CognitoProvider({
clientId: process.env.COGNITO_CLIENT_ID,
clientSecret: process.env.COGNITO_CLIENT_SECRET,
issuer: process.env.COGNITO_ISSUER,
idToken: true,
checks: 'nonce',
}),
],
callbacks: {
// By default NextAuth will redirect to an url of the same hostname
// this callback allows to change that behavior and specify a custom url
redirect({ url }) {
return url;
},
async session({ session, token }) {
// Send properties to the client, like an access_token from a provider.
session.customerID = token.sub;
return session;
},
},
secret: process.env.SECRET,
debug: process.env.NODE_ENV === "development",
}); |
Beta Was this translation helpful? Give feedback.
-
Was able to fix the issue using the My config:
@leonp-s I spent quite a while searching through this thread to eventually find the right solution, maybe one of these comments linking to #4100 can be marked as the correct answer? |
Beta Was this translation helpful? Give feedback.
-
I'm having the same issue: #6865 |
Beta Was this translation helpful? Give feedback.
-
Should we perhaps add the fix as a default in https://github.com/nextauthjs/next-auth/blob/main/packages/core/src/providers/cognito.ts#LL91C10-L91C10 ? options: { checks: "nonce", ...options } |
Beta Was this translation helpful? Give feedback.
-
This same exact nonce mismatch error with |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Question 💬
I am currently trying to use AWS Cognito (setup with a third party IDP) however I am running into an issue when signing in with a third party IDP via Cognito.
A similar question has been asked here, and has been closed however I was hoping a solution might be proposed.
How to reproduce ☕️
Contributing 🙌🏽
Yes, I am willing to help answer this question in a PR
Beta Was this translation helpful? Give feedback.
All reactions