#How to receive Apple user "Name" and "Surname"?

12 messages · Page 1 of 1 (latest)

kind seal
#

I have a Flutter application in which I have Apple social login. I want to receive user Name and Surname from Apple. I have a pre-signup lambda function where I link accounts:

export const handler = async (event, _, callback) => { console.log(event); ... }

The above code prints the following (event):
I couldn't figure out how to get this data.

INFO { version: '1', region: 'eu-central-1', userPoolId: 'eu-central-1_XXXXXXXXXXXX', userName: 'signinwithapple_XXXXXXXXXXXXXXXXXXXXX.XXXXXX', callerContext: { awsSdkVersion: 'aws-sdk-unknown-unknown', clientId: 'XXXXXXXXXXXXXXXXXX' }, triggerSource: 'PreSignUp_ExternalProvider', request: { userAttributes: { email_verified: 'false', 'cognito:email_alias': '', 'cognito:phone_number_alias': '', email: 'my_mail@hotmail.com' }, validationData: {} }, response: { autoConfirmUser: false, autoVerifyEmail: false, autoVerifyPhone: false } }

In Flutter I am calling, signInWithWebUI which doesn't have parameters to handle this situation:
final result = await Amplify.Auth.signInWithWebUI(provider: AuthProvider.apple);

Can any one help with this problem? The Appstore won't accept my application because I am asking users to fill this data right after sign-up is successful.
Thanks.

waxen vessel
#

Hi @kind seal I found a very similar question https://github.com/aws-amplify/amplify-js/issues/10182#issuecomment-1267122344 where the investigation indicates that Apple's limitation may be a blocker for this use case.

GitHub

Before opening, please confirm: I have searched for duplicate or closed issues and discussions. I have read the guide for submitting bug reports. I have done my best to include a minimal, self-cont...

kind seal
#

Hi @waxen vessel , I have seen similar questions and some answers also for react native in which the solution was in the library. I took a look at Apple's documentation and it seems that they provide the user data when credentials are provided:

The information you retrieve must include the credentials required to verify the user’s identity. The server returns the credentials and user information based on the initial request. The information that returns can include user identity, full name, verified email address, and real user status.
https://developer.apple.com/documentation/sign_in_with_apple/sign_in_with_apple_rest_api/authenticating_users_with_sign_in_with_apple#3383773
I think this should be handled with AWS flutter libraries. Maybe in the implementation of Amplify.Auth.signInWithWebUI(provider: AuthProvider.apple);

waxen vessel
#

The doc you linked is for sign in with Apple REAT API, I believe it's different from sign in with web UI

Also, to clarify - are you expecting the Apple returned user info to be available/handled with the call of Amplify.Auth.signInWithWebUI directly on the client side? (I don't think this is allowed as the sign in communication is only between Apple and Cognito.)

kind seal
#

I wasn't expecting to get it in client side. As I thought I would handle (map it) the retrieved data from Apple in the lambda pre-signup function and fetch it in the client from the cognito.

#

By the way, you were right about the REST API link being irrelevant to this case. I think since the webui is used this is the document we have to take a look at:
https://developer.apple.com/documentation/sign_in_with_apple/sign_in_with_apple_js/configuring_your_webpage_for_sign_in_with_apple#3331292
in which some user data is provided:
user: A JSON string containing the data requested in the scope property. The returned data is in the following format: { "name": { "firstName": string, "lastName": string }, "email": string }

#

I don't have expertise on this but I am think Apple is providing these data with the email (which I already receive) with the authentication mechanism since it is one of their requirements of Apple login/sign-up.

waxen vessel
#

Per my understanding, that Apple sends some data to Cognito, and Cognito does some mapping to receive the attributes sent by Apple.
You should be able to control what to be mapped in Cognito console (example documentation: https://aws.amazon.com/blogs/security/how-to-set-up-sign-in-with-apple-for-amazon-cognito/), have you configured the mapping here?

If you have done this, after a user signed in with Apple, do you see Apple sent attributes associated with the user in your Cognito pool?

kind seal
#

I had this mapping and still didn't work (had the same response as before)

waxen vessel
#

Are you always signing in the same user for testing? Apple only sends the attributes once when the user first time to login and link to AWS Cognito

true stratus
# waxen vessel Are you always signing in the same user for testing? Apple only sends the attrib...

https://support.apple.com/en-us/HT210426 has details on how to disconnect your app from your apple login so that it will start again and send all the info when you are testing. https://support.apple.com/en-us/HT210426

kind seal