Accedia / appleauth-net

AppleAuth.NET is a simple library that facilitates the implementation of "Sign in with Apple" for .NET applications.
MIT License
47 stars 26 forks source link

HowTo: Retrieve user information. #28

Open thewayibyte opened 1 year ago

thewayibyte commented 1 year ago

Hello,

can you please tell me how I can retrieve some additional user information? I have received the initial token and then I received a successful response of type "AppleAuth.TokenObjects.AuthorizationToken" in the method "HandleResponseFromApple", is there a way to get user first name and last name?

Thanks

DanailStoichkov commented 1 year ago

You can get the token only the first time the user logs into your app using Sign in with Apple or if you revoke their token (See AppleAuthProvider.cs > RevokeToken method). Then the user will be prompted to a screen where they can choose if they want to share their email or not. After they click continue, in the initial request to your endpoint URL (the one that you have defined in your apple developer portal) will receive a request that contains also a user object:

image
drgrieve commented 1 year ago

This apple feature had me confused for much longer than needed.

For far too long I though the user info was in the jwt id_token.

You can easy miss the one time field when you first start programming Apple outh.

Please consider adding to wiki.

DanailStoichkov commented 1 year ago

@drgrieve You only have the user email there (if the user decides to share it with you). I will put up a schema that depicts the whole sign in flow.

Evon-Simran commented 6 months ago

Is there any way to reterive user details from apple server using sub or userid