Skip to content

SignUp via Google gives OAuthAccountNotLinked error #5397

@ikoichi

Description

@ikoichi

Provider type

Google

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    providerstriageUnseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions