nextauthjs / nextauthjs/next-auth
SignUp via Google gives OAuthAccountNotLinked error
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 28.4k
- Forks
- 4k
- PR merge metrics
- No merged PRs in 30d
Description
Provider type
Environment
System:
OS: macOS 12.3
CPU: (10) arm64 Apple M1 Pro
Memory: 140.63 MB / 32.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 16.15.1 - ~/.nvm/versions/node/v16.15.1/bin/node
Yarn: 1.22.19 - ~/.nvm/versions/node/v16.15.1/bin/yarn
npm: 8.11.0 - ~/.nvm/versions/node/v16.15.1/bin/npm
Browsers:
Brave Browser: 105.1.43.89
Chrome: 105.0.5195.125
Safari: 15.4
npmPackages:
next: ^12.1.4 => 12.1.4
next-auth: ^4.10.3 => 4.10.3
react: ^18.0.0 => 18.0.0
Reproduction URL
https://gist.github.com/ikoichi/d1862344b7f41975481f9686578d74f4
Describe the issue
Only one user in this project (58 signed up with no issues), is not able to signup to my web app using Google and the provider.
I activated the debug mode and collect the logs:
[next-auth][debug][CREATE_STATE]
[next-auth][debug][CREATE_PKCE_CHALLENGE_VERIFIER] {
code_challenge: 'xxx,
code_challenge_method: 'S256',
code_verifier: 'xxx',
PKCE_MAX_AGE: 900
}
[next-auth][debug][GET_AUTHORIZATION_URL] { ... }
[next-auth][debug][OAUTH_CALLBACK_RESPONSE] { ...user profile, account, OAuthProfile, here... }
[next-auth][debug][adapter_getUserByAccount]
[next-auth][debug][adapter_getUserByAccount]
[next-auth][debug][adapter_getUserByEmail]
GET /api/auth/callback/google?paramters....
GET /api/auth/error?error=OAuthAccountNotLinked
In the User table I find the row related to the user, but no row is present in the Account table for this user.
How to reproduce
Sign in is performed using
signIn("google", {
callbackUrl: window?.location ? `${window.location.origin}/app` : "",
})
It is very difficult to reproduce, as it happens only for this specific user (as of now).
Expected behavior
The sign up should succeed.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked reproduction URL and the OAuth callback debug logs, then inspect how the User and Account records are handled for the affected user. Done means the affected user can sign up with Google successfully and an Account row is created for that user.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- next.js, react, typescript
- Domain
- authentication
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100