-
Notifications
You must be signed in to change notification settings - Fork 1.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
Sign in with Apple not passing through fullName #4393
Comments
Thanks for reporting, @RobSwish. I'll try to replicate this on my end and I'll let you know with any updates. |
For the Sign in with Apple UI, it might be an intended behavior that the cross icon displays next to the name, and not changing to a tick. You may check out the same UI here. |
Hi @RobSwish, I was able to replicate the issue you encountered, and this is an expected behavior. The fullName is not returned in Apple's ID token so that we can't use it as displayName directly. However, you may opt to get the fullName through "appleIDCredential.fullName" in didCompleteWithAuthorization delegate method, and update user's profile by yourselves. Additionally, it is mentioned here that Apple only shares the address with apps the first time a user signs in. |
Going to close this, since there's no obvious actions for us. Feel free to follow-up if you have more questions. |
The documentation here says that:
But this is not the case. I was able to update my user based on @rizafran 's comment (thanks!) but that is not what the doc says. So either changing the docs or making the code do what the docs say would be nice (this last option would be preferred in my opinion!) |
@renkelvin based on my understanding we should update the documentation here, not the SDK behavior. Is this correct? |
Thanks a lot! You got back to me so quickly I didn't notice, sorry! I do think that the default behaviour should be for Firebase to save the name if it can as this is what it does for the other sign in methods such as Facebook and Google. But it's good to know I can get the name through the other way you have mentioned. |
I talked to @renkelvin about this and he mentioned that the current behavior exists because Sign In with Apple's behavior is inconsistent with the other authentication providers (Sign In with Apple does not always return the user's name). I don't think Firebase saving the name to the user by default is a good idea since it makes it easier to accidentally link the name to other identifiable information, which is against Apple's license agreement if the user has chosen to anonymize their sign in info. Unless this proves to be a significant pain point during development, we're likely not going to change the Firebase SDK behavior, though we can add this as an opt-in automatic behavior in FirebaseUI (see firebase/FirebaseUI-iOS#815). |
@morganchen12 How is the fullName differs from the email address in this case? If the app requested both fullName and Email Below is the relevant part from the agreement:
` |
I've re-created the scenario where an Apple user is new and signs in for my app for the first time, and still, Firebase's user (FIRUser) held a null displayName. |
I have the same problem. I removed my app from the list of apps I use Apple Auth with but while signing in I still don't get back the name of the user. |
Thanks all, I'll take another look at this issue. |
Hello, do we have an update on this issue? I'm an experiencing it, as well. |
Hi, I am also having this issue. Is this being worked on? |
I'm not sure, but I was able to find a work around that appears to work. The name is available only on the first time authenticating with Apple. In the authorizationController method that is in the docs, take the variable appleIDCredential that is given, and grab both the first and last name. For me, I had variables that looked something like: firstName = appleIDCredential.fullName?.givenName Once you get those names saved as variables, be sure you save them to the DB, as you will not be able to access them again. Hope this helps you out. |
I am experiencing the same problem. Question: What does "The name is available only on the first time authenticating with Apple" mean exactly? |
It means you'll get the name from Sign in with Apple whenever Apple feels like giving it to you. Sign in with Apple is hostile to systems that try to save PII by design. If you want to guarantee an alias for your user, prompt them to input a display name. |
I think the docs need to be updated to reflect the current behavior, or the behavior needs to be fixed. This issue has been open for quite awhile. |
I do now know, what the solution to the problem is.
if let fullName = appleIDCredential.fullName { and via: let changeRequest = user.createProfileChangeRequest() // (3) you tell Firebase to store the name into your profile. For detailed information, please look into Peter Friese's Blog. Best regards from Heiko |
I would like to point out that the behavior is different for Firebase on the web. Using that framework the display name is provided. |
I can’t get the above solution to work at all. Peter Friese has a great article, but I cannot get his solution to yield any positive results. Anyone have a working example as of Swift 5.2? |
The values are being returned from Apple, populating it in the displayName would make life much easier:
Above returns a credential with the required values from Apple
But it doesn't get added to the authResult values |
Apple is rejecting apps if they don't pre-fill user name fields in-app with the name given by apple during apple authentication, so this really needs to be fixed, as it blocks apps from being successfully submitted to the AppStore. |
Is there a agreed upon workaround for getting the display name? |
This is a patch that I used in a fork I made of https://github.com/firebase/flutterfire.git, which saves the given+family name from the credentials provided by Apple to SharedPreferences, which our app then can retrieve later. It was applied to the flutterfire_ui 0.4.0+5 state - https://gist.github.com/mbevin/393597735c67575eccf0858c4c17168d |
Same issue Auth.auth().currentUser.displayName not getting the name after apple sign in via firebase. App has been rejected from ios store . |
This is being worked on in #10068 (Add Sign in with Apple Display Name API and unit test). |
@peterfriese Is there any update on #10068? I would use the workaround above; however, I am using Flutter with the Firebase Auth package so that would be a bit of a pain unless I absolutely need to. |
Let me check with the team, @GregoryConrad ! |
Hello, this is absolutely needed because Apple is rejecting apps. Urgency is needed on this issue @peterfriese . |
Our app just got rejected as well. :( |
We were able to work around the submission it by not asking for a name |
A video explaining how to update the display name is going live tomorrow. In the meantime, check out this code snippet (source: https://bit.ly/SiwA-updateDisplayName): func updateDisplayName(for user: User, with appleIDCredential: ASAuthorizationAppleIDCredential, force: Bool = false) async {
if let currentDisplayName = Auth.auth().currentUser?.displayName, !currentDisplayName.isEmpty {
// current user is non-empty, don't overwrite it
}
else {
let changeRequest = user.createProfileChangeRequest()
changeRequest.displayName = appleIDCredential.displayName()
do {
try await changeRequest.commitChanges()
self.displayName = Auth.auth().currentUser?.displayName ?? ""
}
catch {
print("Unable to update the user's displayname: \(error.localizedDescription)")
errorMessage = error.localizedDescription
}
}
} Also, we are working on updating the display name when the user first signs in with SiwA. As this requires some backend changes, it might take a couple more weeks to land. I will keep this bug updates as we make progress. |
Just to clarify: are you saying that in a couple weeks, apps will have the |
See PR #10068 which contains the front-end work for this. |
We are using FirebaseAuthUI, so this workaround should be implemented by Google too. @peterfriese |
Hi everyone, I am happy to report that we've merged the code for setting the user's displayname to the SiwA full name when authenticating with Apple (#10068). You can set the displayname to the SiwA fullname like this: // Initialize a Firebase credential, including the user's full name.
let credential = OAuthProvider.appleCredential(withIDToken: idTokenString,
rawNonce: nonce,
fullName: appleIDCredential.fullName) Docs and QuickStart have been updated: |
Thanks @peterfriese and team! 🎆 |
Problem
I have added "Sign in with Apple" to my app. It all works perfectly except it does not pass the name through when authenticating. I am asking for full name and email in my code.
request.requestedScopes = [.fullName, .email]
The Sign in with Apple UI does display a cross next to the name, I don't know if it is supposed to show a tick, I've tried tapping this and changing my name but it does not change to a tick.
I can confirm through debugging that the "displayName" property of the Firebase user is nil after creation.
Relevant Code:
request.requestedScopes = [.fullName, .email]
The text was updated successfully, but these errors were encountered: