Flutterfire: [Auth] Email & Name not being retrieved when using Apple Sign-In

Created on 28 Apr 2020  Â·  12Comments  Â·  Source: FirebaseExtended/flutterfire

Describe the bug
When using Apple Sign-In, the Apple credential has the user name and email, then, registering (or binding) the credential to Firebase using both idToken and authorizationToken, will result in the FirebaseUser not having neither displayName nor email associated.

To Reproduce
Steps to reproduce the behavior:

  1. Use either apple_sign_in or sign_in_with_apple to create a valid Apple sign-in;
  2. Create an AuthCredential using OAuthProvider getCredential() method;

Expected behavior
Expect the user to have name and email — doesn't happen.

Additional context
firebase_auth: 0.15.5+3

Flutter doctor
Run flutter doctor and paste the output below:

[✓] Flutter (Channel stable, v1.12.13+hotfix.9, on Mac OS X 10.15.4 19E287,
    locale pt-PT)
    • Flutter version 1.12.13+hotfix.9 at /Users/miguelruivo/devtools/flutter
    • Framework revision f139b11009 (4 weeks ago), 2020-03-30 13:57:30 -0700
    • Engine revision af51afceb8
    • Dart version 2.7.2
Stale customer-response closed-by-bot ios auth needs-repro user bug

Most helpful comment

@Salakar Any news on this? This seems like an easy fix. The info is there. As of now, the apple sign lacks usability as this is supposed to replace registration. Not having the name or an email we get an incomplete registration and then we need to ask the user a name, manually. @miguelpruivo thanks for opening this issue.

All 12 comments

Hey @miguelpruivo

I believe this is working as intended;

Apple only returns the full name and email on the first login on the device for your app, it will return null values for these on any login after that. My guess is that you've signed in previously and then tried to sign-in again via a new Firebase Auth user and the Name/Email is no longer available at that point.

For testing purposes, to receive these again; go to your device settings; Settings > Apple ID, iCloud, iTunes & App Store > Password & Security > Apps Using Your Apple ID, tap on your app and tap Stop Using Apple ID. You can now sign-in again and you'll receive the full name and email again.

This is how Apple has designed their API - so it's recommended that you store these elsewhere on your app, e.g. using the shared_preferences plugin - so that you consistently have access to them when required.

@Salakar I'm aware of that, and this happens on a fresh install as soon as the first binding is made. I expect that when a sign in to Auth uses the credential with a name & email, those should be kept on the auth credential itself, which definitely aren't.

Am I missing something?

Thanks.

How are you requesting the credential from Apple, are you adding the email & full name scopes?

@Salakar sure. Like I said, when debugging, I can see the name & email are there. Then, immediately after

final AuthorizationResult appleSignin = await AppleSignIn.performRequests([
      AppleIdRequest(
        requestedScopes: [Scope.email, Scope.fullName],
        requestedOperation: OpenIdOperation.operationLogin,
      )
    ]);

  if (appleSignin.status == AuthorizationStatus.authorized) {
      OAuthProvider oAuthProvider = OAuthProvider(providerId: "apple.com");  

  // Until this point, I can access the email & password from `appleSignin` credential. 
    credential = oAuthProvider.getCredential(
        idToken: String.fromCharCodes(appleSignin.credential.identityToken),
        accessToken: String.fromCharCodes(appleSignin.credential.authorizationCode),
      );
    }

FirebaseUser user = await _auth.signInWithCredential(credential); // here, the user doesn't have it.

Thanks for the code example;

Is this just iOS that has the issue? Are you using any other OAuth providers and seeing the same behaviour?

Currently I'm only using Sign In with Apple on iOS devices so I can't really tell if this is happening on Android as well — I believe that's less common to have users logging with Apple on Android devices anyway.

As for the second question, this is the only OAuth provider that I'm using. Both Facebook and Google have their own static methods to get an auth credential (ie., FacebookAuthProvider.getCredential() and so on).

@Salakar Any news on this? This seems like an easy fix. The info is there. As of now, the apple sign lacks usability as this is supposed to replace registration. Not having the name or an email we get an incomplete registration and then we need to ask the user a name, manually. @miguelpruivo thanks for opening this issue.

@Salakar Any news on this? This seems like an easy fix. The info is there.

What would you suggest the fix be? Could you send a PR over for it if it's still an issue on the latest auth release?


Hey @miguelpruivo. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!


Since there haven't been any recent updates here, I am going to close this issue.

@miguelpruivo if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.

Re-open. The issue still persists.

Can you please open this issue again i am having the same issue too

Was this page helpful?
0 / 5 - 0 ratings