-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Unable to Link Apple Account to Other Existing User Account #6480
Comments
We use the e-mail address to link accounts. If you use email proxies, Apple likely generates a new e-mail on each login, so we cannot link the accounts and a new user is created: next-auth/packages/next-auth/src/providers/apple.ts Lines 52 to 54 in 6ecf9cb
Sidenote: unavailable.com is not a reproduction... |
This doesn't line up with my testing, I see the following (confirmed no proxies were used)
In the nextauth source code, linking happens on userId:
@balazsorban44 can you elaborate more on this? |
Additionally, I'm not receiving a name when using the Apple provider. Is there a chance that I have something wrong with my configuration within Apple? |
Yes, there is a chance. Apple's OIDC is a bit messy from my experience... We will need a reproduction in any case, the problem is I don't have an Apple dev account. To create one, I apparently need an Apple device, which I don't own, and they want my address which I don't want to give. 🤷 I also tried registering as an org (for Auth.js), but we don't have the legal stuff (not truly an organization), and would likely have to pay. Apple just seems to not care about the developer experience. This is a true headache, but you can reach out on Twitter and maybe I can have a look together with you for a bit. Just make sure you have a super-simple reproduction ready. |
Good day @balazsorban44! I have created a reproduction repository that you and your team to look over. Here is the link for this: https://github.com/RayBans2111/nextauth-apple-bug-troubleshooting |
Provider type
Apple
Environment
"react": "18.2.0",
"next": "12.2.5",
"next-auth": "^4.10.3"
I am running Node 18.13.0 on a Windows 11 machine. I am using Google Chrome as my development browser. Issue also happens in Microsoft Edge.
Reproduction URL
http://unavailable.com
Describe the issue
When going through the process of linking an Apple Account to an existing user account (that was created with Google or Microsoft), upon signing in through Apple's portal, an entirely new account is being created instead of being linked to the existing user account.
The next-auth cookies are not present when taking a look at the request headers for api/auth/callback/apple, and this is probably what is causing the issue.
Here is my snippet of NextAuth code for the providers:
Here is a small snippet of example buttons:
Snapshot of apple request headers after signing in (no nextauth cookies present)
Snapshot of google request headers after signing in (cookies present)
How to reproduce
Expected behavior
When clicking on the sign in with Apple button (while already signed in with your other provider account), I should be able to sign in with Apple, and return to my project with the account linked rather than NextAuth creating a new user account.
The cookies should also be visible/present in the api/auth/callback/apple request headers.
The text was updated successfully, but these errors were encountered: