apple-auth icon indicating copy to clipboard operation
apple-auth copied to clipboard

Email is missing in JWT returned from Apple SSO

Open realkoder opened this issue 1 year ago • 3 comments

Hi there,

I have been troubleshooting an issue for several days and would appreciate any insights you might have. When using the apple-auth library, I'm able to receive all necessary data from Apple without encountering any HTTP errors or exceptions. However, I am not receiving the email field in the decoded JWT payload from response.id_token.

Interestingly, this issue only occurs for users other than myself. When I use my own Apple ID, which is connected to my Apple Developer account (where all configurations are stored), I receive the email without any problems. However, for other users, the email field is missing in the JWT payload.

Has anyone experienced a similar issue, or does anyone know how to resolve this?

Thank you in advance for your help.

Best regards, Alexander

realkoder avatar Sep 19 '24 08:09 realkoder

hi @realkoder, the email and other profile is shared only once (when the person registers). At that time, you're supposed to store the email and all other details. After subsequent logins, you'll only get the sub parameter from Apple which is the unique identifier. You have to match the sub parameter from response.id_token with the email stored by your DB during the first login.

ananay avatar Sep 19 '24 08:09 ananay

Thanks a lot for getting back to me this fast! Really appreciated

I've read that before so I am aware that first signin for client is the only time where name is returned didn't know it's the same with the email. But how come every time when I use my own AppleId for Apple SSO I get my email returned in the JWT? Could that be because my appleId is connected to the apple dev account I'm using?

Sorry for my confusion 🤪

realkoder avatar Sep 20 '24 06:09 realkoder

Okay never mind - I just thought that the email was returned every time a client would sign-in using Apple SSO. I'm just an idiot.... This means my setup has worked for a long time now hahahah, which I didnt believe it did... :')

realkoder avatar Sep 20 '24 08:09 realkoder