Skip to content
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

[Question] Does hiding email also hide a user's name? #38

Closed
harrisrobin opened this issue Feb 13, 2020 · 3 comments
Closed

[Question] Does hiding email also hide a user's name? #38

harrisrobin opened this issue Feb 13, 2020 · 3 comments

Comments

@harrisrobin
Copy link

Hi,

Trying apple sign in on the simulator, if I hide email but decide to share my name, I don't get the user's name at all.

displayName is null
username is null, etc.

Am I missing something? Does hiding email always hide a user's name?

@mikehardy
Copy link
Collaborator

unknown, you might be the authority on this if you double-check the Obj-C directly ( good sample code here https://developer.apple.com/documentation/authenticationservices/implementing_user_authentication_with_sign_in_with_apple ) and probe the various bits. Also worth checking the apple developer forums though it seems (based on an issue I had last week, and searches I made) that not many have explored it much yet

@edgarbonillag
Copy link

edgarbonillag commented Mar 4, 2020

Hi @harrisrobin It looks that you are getting the displayName from the Firebase user credential because the Apple credential itself doesn't return any field named displayName, as Firebase does.

If that's your case, I was having the same issue, and I found that the user's name is not returned in Apple's token (as exposed here) so Firebase is not able to get that. But if you need the user's name, you can get it from the Apple credential that is returned by appleAuth.performRequest() as you can see here in the API Docs.

So basically, you can do:

const responseObject = await appleAuth.performRequest({
    requestedOperation: AppleAuthRequestOperation.LOGIN,
    requestedScopes: [AppleAuthRequestScope.EMAIL, AppleAuthRequestScope.FULL_NAME],
});

And then get the info you need from:

responseObject.fullname.familyName
responseObject.fullname.givenName
responseObject.fullname.middleName
responseObject.fullname.namePrefix
responseObject.fullname.nameSuffix
responseObject.fullname.nickname

And then manually upload it to Firebase, or replace the displayName or do what you need with the name.

Remember that this info is only returned the first time the user signs in, as exposed in #17.

@harrisrobin
Copy link
Author

Hi @harrisrobin It looks that you are getting the displayName from the Firebase user credential because the Apple credential itself doesn't return any field named displayName, as Firebase does.

If that's your case, I was having the same issue, and I found that the user's name is not returned in Apple's token (as exposed here) so Firebase is not able to get that. But if you need the user's name, you can get it from the Apple credential that is returned by appleAuth.performRequest() as you can see here in the API Docs.

So basically, you can do:

const responseObject = await appleAuth.performRequest({
    requestedOperation: AppleAuthRequestOperation.LOGIN,
    requestedScopes: [AppleAuthRequestScope.EMAIL, AppleAuthRequestScope.FULL_NAME],
});

And then get the info you need from:

responseObject.fullname.familyName
responseObject.fullname.givenName
responseObject.fullname.middleName
responseObject.fullname.namePrefix
responseObject.fullname.nameSuffix
responseObject.fullname.nickname

And then manually upload it to Firebase, or replace the displayName or do what you need with the name.

Remember that this info is only returned the first time the user signs in, as exposed in #17.

That worked, thank you 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants