Next-Auth: Try signing in with a different account.
So this error I am getting in the browser This is very common. It usually doesn't tell me what's wrong.
The first thing I do when I see this is check my environment variables. Checking if theyre correct. Which they are.
I am using
create-t3-app
So it also checks that for me by default.
I am added a Google Provider and when I click on sign in with google, It doesn't redirect me to the correct page. It instead brings me to the /api/auth/signin
page with an error message.
This is also happening, it redirects me to api/auth/signin?error=OAuthAccountNotLinked
And I see this error
Any idea what's going on?5 Replies
I also have a feeling it has something todo with the prisma schemas, so here are the schemas used by Next-auth:
I dropped all the tables in the planetscale console and tried it again,
I tried sigining in with google first, which got me this error
Then with Linkedin, same error. Then I tried it with Discord and I got succesfully signed in.
That's probably because you are trying to access it through different social accounts that share the same email. If you've made an account, let's say, with Linkedin and then with Google, and both of them share the same email, nextauth will throw an error.
You can check https://next-auth.js.org/faq#security for reference. - The "When I sign in with another account with the same email address, why are accounts not linked automatically?" question in particular
Frequently Asked Questions | NextAuth.js
About NextAuth.js
Oh i forgot to mention I've tried it with another google account
I have tried with another discord account with a different email
From my knowledge, the only time you can get
api/auth/signin?error=OAuthAccountNotLinked
is "If the email on the account is already linked, but not with this OAuth account". The OAuthAccountNotLinked
error is also documented in the https://next-auth.js.org/configuration/pages#sign-in-pagePages | NextAuth.js
NextAuth.js automatically creates simple, unbranded authentication pages for handling Sign in, Sign out, Email Verification and displaying error messages.
look at the error in your terminal, theres a link to a next auth documentation page