-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Bug causing OAuthAccountNotLinked (identified in a recent commit) #9878
Comments
This comment has been minimized.
This comment has been minimized.
I can confirm my users who used GitHub can no longer sign-in again. |
@robinbraemer this only happened in the experimental/beta version of the libs, which are not yet production ready as the release tag suggests, and you are using them in production at your own risk. Every update you do is your own responsibility. We have extensive changelogs where you can check the changes before upgrading and take an evaluation, and reach out if something doesn't look right to you. "same issue" messages are of little value as comments, the rest of your message is also unnecessary. You can 👍 the original post to show that you are having a same/similar issue, unless you can provide more context. Luckily, the OP did an amazing job here and took the time to dig deep, making it fairly easy to see the problem 💚. Will look into this as soon as my time allows it. I'm sorry if our free beta library caused issues for your users, make sure to sponsor the project if you need quicker support in the future. PRs are of course always welcome! |
Having the same problem, I am using Google and GitHub providers. When I set Update 1: |
@balazsorban44 thanks for your answer, I will send a PR asap. I understand that this issue being on the experimental branch does not make it the top priority. However I'm using the svelkit authjs library which seem to rely on the authjs core experimental version (let me know if I'm wrong). Since this sveltekit lib is now used by a bunch of folks I wonder if there is any plan to make it rely on the production ready branch of authjs core instead. Since the sveltekit package is simple a client around the authjs core, it would be nice to be able to choose the core version we wanna use or at least base it on the production ready version. Happy to open another issue / PR for this if it makes sense to you. |
Both libraries (core and sveltekit) are experimental, it's implied on the docs. There's no "stable" core yet. As you see from this issue, we still have things to figure out. It is top priority though. My time is just limited. |
Attention to Those Affected: If you're experiencing issues, revert to the last stable release by running: Steps to Fix Broken User Accounts"broken user accounts" can no longer re-login after signing out. 1. Identify Affected AccountsTo locate accounts created during the period when the faulty version was active, execute the following SQL query (assuming you used postgres/prisma): SELECT t.*
FROM public."Account" t
WHERE "providerAccountId" LIKE '%-%' This query targets Warning: This method is verified for GitHub and Discord OAuth providers, whose account IDs comprise only integers, lacking dashes. If your account IDs from other providers normally include dashes, this approach may not be suitable, and an alternative method to identify affected accounts will be necessary. 2. Update the
|
For those using |
This comment was marked as off-topic.
This comment was marked as off-topic.
@machak while I appreciate feedback (even negative one), your comment has nothing to do with this issue, and helps nobody solving the reported issue. Please keep future discussions to the case in point. As such I'm marking it as off-topic. This is open-source, people helping you and your company for free. Not a competition. Consider sponsoring the projects you want to see succeed to accelerate their development, if you are not satisfied with the development speed. Also, we welcome PRs! That said, everyone, please use whatever tools make you happy. |
Should be fixed in |
Unfortunately is not fixed. Still have issues after clean install.
|
@demenskyi open a new issue with a reproduction. gonna lock this one, as the OP's issue should be resolved. Please generally don't comment to already closed issues, it's only by chance that I read this again. |
Environment
System:
OS: macOS 13.5
CPU: (12) arm64 Apple M2 Pro
Memory: 86.23 MB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.5.1 - ~/.nvm/versions/node/v20.5.1/bin/node
npm: 9.8.0 - ~/.nvm/versions/node/v20.5.1/bin/npm
pnpm: 8.7.0 - ~/.nvm/versions/node/v20.5.1/bin/pnpm
Browsers:
Chrome: 121.0.6167.139
Safari: 16.6
Reproduction URL
https://github.com/kevinpiac/next-auth-providerAccountId-issue
Describe the issue
As a user, when I try to sign in for the second time using an OAuth or OIDC provider such as Google for example, I keep getting the
OAuthAccountNotLinked
error even if I'm using the same Provider and the same account.It seems this bug was introduced by this recent fix: #9793
This fix always overrides the
user.id
tocrypto.randomUUID()
Then it sets the
providerAccountId
touser.id
instead of using the id returned by theprofile callback
as specified in the documentation (see below).This causes the providerAccountId to be randomly generated every time someone tries to login and will always cause OAuthAccountNotLinked error.
The docs say:
For more context, see the two incriminated lines below:
How to reproduce
In summary :
More detail :
On the first sign-in an
Account
is persisted using the adapter with aproviderAccountId
that is not corresponding to the id field returned by the profile callback. It uses a random UUID instead.So, the second time the user tries to sign in, it triggers an
OAuthAccountNotLinked
error because the adapter tries to find the matchingAccount
using a new random UUID, causing theOAuthAccountNotLinked
to throw.Expected behavior
It should follow the documentation, and the providerAccountId should be equal to the result of the user.id returned by the profile callback.
The text was updated successfully, but these errors were encountered: