-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
fix: Add features missing for Apple provider #8189
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
|
@ChrGrb is attempting to deploy a commit to the authjs Team on Vercel. A member of the Team first needs to authorize it. |
Co-authored-by: Balázs Orbán <[email protected]>
Co-authored-by: Balázs Orbán <[email protected]>
I'm hesitant about merging this yet, as we don't want to make exceptions for handling providers specifically in the core library. Apple is making this hard here, not adhering to the OAuth spec... User information should be in I recently figured out how to finally test an Apple provider (had to pay for it 👎) myself, so I'll think about it a bit more. *Venting*: Apple really does not want people to use their provider. 😅. By far the most convoluted/worst documented provider, and not even free... |
I 100% agree with what you say. Figuring out what is going wrong and why is a nightmare with the Apple provider and changing the core did feel off. I did have 2 possible alternatives to this, that could be considered: Make the provider usable with the current core functionality
the response is returned in the url, instead of the body. Add the ability to provide a custom Either way, if you need any assistance or get stuck, just hit me up. I know how hard it is to find documentation or information on this topic. This article highlights some of the differences between OAuth2 and the Apple version pretty well. It also explains, why the pkce cookie does not arrive back with the callback as expected: https://www.bscotch.net/post/sign-in-with-apple-implementation-hurdles |
Doing some more digging I found that Apple actually does adhere to the OIDC spec. This is the actual, expected behaviour for an OAuth2.0 form_post request. It is just that apparently no other provider in Auth.js uses this. https://openid.net/specs/oauth-v2-form-post-response-mode-1_0.html#FormPostResponseExample This does, in my opinion, justify changing the core. It is practically speaking not changing it for a single provider, but instead for all potential future providers using the same form_post spec. |
My ick is with specifically returning the user data in a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's revert the last changes, it's not the correct way to handle this IMO.
(closed by accident, sorry).
I'm thinking of something similar. See next-auth/packages/core/src/lib/oauth/callback.ts Lines 111 to 115 in 60c5037
Here, if a provider is not adhering to the spec, we let them call into this .conform method, signaling that this is really on the provider and not on us. Also warning for the users so they can let us know when a provider finally fixed their stuff.
An example is Twitch: next-auth/packages/core/src/providers/twitch.ts Lines 88 to 115 in 60c5037
|
This reverts commit 503830c.
I tried my best to implement your idea. I could not figure out a way on how to do it with only the existing conform methods, as the What I did instead is create a Additionally I added the |
fa96b45
to
65aa467
Compare
May I ask if there's any progress in merging this PR? I'm currently using the fallback suggested here but with that the email is reported as null since it can't be part of the scope. |
I can successfully sign into Apple, but this issue continues to be a problem for me since the failure to be able to get an email returned from Apple on a Vercel implementation makes the Apple provier unusable for my purposes. After digging into it, it looks like the fix should be pretty simple: since Apple returns the state in the body of a POST (which one would expect for a POST, and is frankly better security practice) rather than as a GET query parameter (which is what the state check is looking for), the following approach should address the problem:
I'd try to fix this myself, except I've never tried to submit a pull request and I'm on a tight time deadline on this project and the other providers (Google, Facebook, Auth0, and Github) all work fine so I can proceed without Apple. But given the ubiquity of iPhones, it would be great if Apple would return an email address in a Vercel implementation. Love this library, and appreciate all of the hard work that has gone into what is an elegant solution to a tough problem. Cheers, |
We've hit this issue ourselves and, short of modifying the core which I don't feel qualified to do, it doesn't seem we have any recourse on this other than to hope this PR exposing the form data vs query approach gets merged. We'd really appreciate if this could keep moving forward 🙏 |
I've run into the same issue, it seems the Apple Auth simply doesn't work currently. I've tried 5.0.0-beta.20 and 5.0.0-beta.21 following the documentation and the issue is a server error that occurs after successfully logging in and authenticating on the Apple side then redirecting to the callback url which throws an error. I've also tried some workarounds that were posted but they did not work either. |
Is there a reason this wasn't merged? We are blocked due to this and so far none of the workarounds we've tried work. It would be awesome if we could get an update here @ChrGrb @balazsorban44 @ThangHuuVu |
You are not blocked. You can copy-paste the code whenever you want and use something like I honestly just don't like that we would need a workaround like this, just for the sake of Apple... My opinion is the same as #8189 (comment), Apple is one of the worst providers to work with, by far... |
Does this mean that Auth.js will not support Apple login, and that the documentation around Apple OAuth support needs to be removed? For me it's a pretty big deal, Apple is one of the largest mobile device markets so to not have their login is a very large negative for me. To be fair it clearly isn't following standards and would require more work to deal with the disappearing email, I may rethink using it altogether but it's an annoying gap for sure. |
Never said we don't want to support it. Just not the way it's presented in this PR. Recently merged #11975 which might help resolve this. Maybe not. Maybe it's gonna be like adbe451 I've spent years pushing the standards, and removing workarounds from the core. I trialed Twitter OAuth 2 before it came out and gave them early feedback so it would be compliant. I talked LinkedIn into fixing their issuer. Microsoft and Apple will be too much for me, I guess, and have to cave in and add hacks to the core to support them. And at the end, people are still mad at me for not shipping a solution quicker... |
@balazsorban44 Ok awesome, thanks for the insight, I definitely appreciate your efforts! |
☕️ Reasoning
Changes to routes/callback.ts
Changes to providers/oauth.ts
Changes to providers/apple.ts
🧢 Checklist
🎫 Affected issues
Fixes:
📌 Resources