Gitlab OAuth Error
Hello! After upgrading to 3.8.0 we're facing a issue with gitlab oauth.
When I try to log in, I receive:
[31m[auth][error][0m OAuthAccountNotLinked: Another account already exists with the same e-mail address. Read more at https://errors.authjs.dev#oauthaccountnotlinked
The thing is, I dont have any other linked email (its a sign in, not a sign up).
I got few data:
(Screenshot 1)
(Screenshot 2)
(Screenshot 3)
Complete log error:
Thanks in advance.


3 Replies
Found the culprit!
The issue is: next-auth in v5.0.0-beta.28 changed how gitlab auth should work.
Its now using
profile.sub
(Reference: https://github.com/nextauthjs/next-auth/commit/2da115c6649e1d98aee33b364efa2c412608898b)
Before it was profile.id, they even had a discussion about it.
Reference: https://github.com/nextauthjs/next-auth/pull/11176
sub is for oidc ONLY, not for oauth.
Thats way this code can break authentications.
The resolution for now is simples, we can just inject the method on gitlabProvider.
See Attachment 1.
Did few tests and that worked as expected!
I'll send an PR with this.
GitHub
fix(gitlab-auth): patch profile parsing for next-auth@v5 compatibil...
🚑 fix(gitlab-auth): patch profile parsing for next-auth@v5 compatibility
Description
Fixes a compatibility issue with GitLab authentication after upgrading to next-auth@v5.0.0-beta.28.
Starting fro...
Appreciate the contribution 🙂