Quickstart-android: Email not appearing for FirebaseUser when used with GoogleSigninActivity

Created on 23 May 2016  路  14Comments  路  Source: firebase/quickstart-android

This may have been inherited from FirebseAuth, when logging in with Google account the firebase user email is empty/null.
Seems we have to manually update email whereas photo Url is seamlessly picked up by firebase user !

Till few days ago (com.firebase) when users were added with google sign-in, email was added automatically as seen on users console.

Most helpful comment

This might be related:
In Firebase console under Auth -> Sign in method -> Advanced there is an option called "One account per email address". If this is Not checked (seems to have been the default), the users emails will be blanked when they sign in.

I checked this option, removed my users and logged them in again and the email is now there in both console and client.

All 14 comments

@nycodes9 can you try the following steps:

  • Uninstall the app
  • Re-install the app
  • Go directly to GoogleSignInActivity
  • Sign in

Is the email still null in that case?

Yes tried all variations - with no different outcome.

@nycodes9 @morphine9 are you requesting email in your GoogleSignInOptions?

@iainmcgin do you know of a situation where email would be null from Google Sign In?

GoogleSignInOptions gso = new GoogleSignInOptions.Builder(
                GoogleSignInOptions.DEFAULT_SIGN_IN)
                .requestIdToken(getString(R.string.default_web_client_id))
                .requestEmail()
                .requestProfile()
                .build();

Ok those are the correct GoogleSignInOptions. Does this happen when you use a different google account to sign in?

Same google a/c with which I'm registered with firebase.

@morphine9 can you capture the output of adb logcat during a sign-in attempt and upload it here? If it's large you can use a pastebin or similar.

This might be related:
In Firebase console under Auth -> Sign in method -> Advanced there is an option called "One account per email address". If this is Not checked (seems to have been the default), the users emails will be blanked when they sign in.

I checked this option, removed my users and logged them in again and the email is now there in both console and client.

@ptornhult I have reproduced the behavior you just described, thanks for the tip! This is surprising to me, but I will check with the authentication team to see if this is the expected behavior.

@ptornhult I have confirmed this is the intended behavior when you have multiple users per email address enabled. We will be updating documentation to make this clearer so we have fewer surprised developers.

@nycodes9 I believe the information above should answer your question, closing this issue. If you think there is a different cause to your problem, please reply and I will re-open.

@ptornhult Great find! Thank you.

How are we supposed to link the accounts using firebase admin sdk, if we do need to allow multiple accounts using same email address (and different social providers) ?

This might be related:
In Firebase console under Auth -> Sign in method -> Advanced there is an option called "One account per email address". If this is Not checked (seems to have been the default), the users emails will be blanked when they sign in.

I checked this option, removed my users and logged them in again and the email is now there in both console and client.

this still doesn't work for me even after this suggestion. the email field is still null.

Update

Looks like these are the steps :

Go to your project console -> Authentication -> Sign-In Method -> One account per email address (Prevent creation of multiple accounts with the same email address).

Delete created account, and sign in again, now you can get email address.

Was this page helpful?
0 / 5 - 0 ratings