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

Email is null for Google Sign-in for some accounts #1621

Closed
davidvavra opened this issue Apr 16, 2019 · 16 comments
Closed

Email is null for Google Sign-in for some accounts #1621

davidvavra opened this issue Apr 16, 2019 · 16 comments

Comments

@davidvavra
Copy link

After a successful Google sign-in, I'm getting null when calling FirebaseAuth.getInstance().currentUser?.email Other fields (displayName, uid) are there.

This is how I launch the Auth UI:

 activity.startActivityForResult(
                AuthUI.getInstance()
                        .createSignInIntentBuilder()
                        .enableAnonymousUsersAutoUpgrade()
                        .setLogo(R.drawable.ic_splash_app)
                        .setTheme(R.style.LoginTheme)
                        .setIsSmartLockEnabled(false, true)
                        .setAvailableProviders(listOf(
                                AuthUI.IdpConfig.GoogleBuilder().build(),
                                AuthUI.IdpConfig.FacebookBuilder().build(),
                                AuthUI.IdpConfig.EmailBuilder().build()))
                        .setTosAndPrivacyPolicyUrls("https://settleup.io/privacy_policy.html", "https://settleup.io/privacy_policy.html")
                        .build(),
                Ids.REQUEST_SIGN_IN)

It's strange, because I'm only getting this behavior for some Google accounts. Others are fine. I also see email in the Firebase Console for all accounts.

My "One account per email address" is set to "Prevent creation of multiple accounts with the same email address"

This started to happen after I updated the library from version to version 2.0.1 to version 4.3.2.

@samtstern
Copy link
Contributor

@davidvavra did those users previously log in with any other identity provider?

@davidvavra
Copy link
Author

davidvavra commented Apr 17, 2019

@samtstern Those users could login before with Google provider. I'm suspecting that this issue is connected with 2 step verification. So far I have reproduced it on 3 Google accounts with 2 step verification turned on. Other accounts without it work.

@samtstern
Copy link
Contributor

Hmmm @davidvavra ok a few more questions:

  • When you mention 2-factor auth are you just saying the accounts have it enabled or you're going through the whole 2FA flow on the phone during the sign-in attempt?
  • If you sign out (don't delete the account) and sign back in as the same user is the email always null?
  • Did you ever sign in to your app with a Facebook account with an email that matches these problematic accounts?

@davidvavra
Copy link
Author

The accounts have it enabled, there is no 2FA flow during sign-in attempt.

If I sign out and sign in, it's the same problem.

I might have signed in with Facebook before just for testing purposes, but deleted the Facebook account from the Firebase console afterwards. Otherwise the library doesn't allow signing with Facebook if I used Google before (I have one account per email enabled)

@davidvavra
Copy link
Author

I did some additional testing and it looks like the 2FA is not the cause. I was able to sign in with newer accounts with 2FA turned on. Only thing which connects these accounts is that they are older - created in 2016. @samtstern

@samtstern
Copy link
Contributor

Hmmm that is so strange. @lsirac @malcolmdeck any ideas?

@lsirac
Copy link
Contributor

lsirac commented Apr 25, 2019

Hmm, can you check if there are duplicate accounts with the same email in the Firebase Console?

@davidvavra
Copy link
Author

@lsirac Yes that actually happened. These accounts had a duplicate Google account in the console. One of them wasn't used since 2016. But when I deleted this old account, the behavior is still the same - no email.

@lsirac
Copy link
Contributor

lsirac commented Apr 25, 2019

What if you delete both accounts and sign in again?

@davidvavra
Copy link
Author

These are user production accounts, I can't delete them.

@lsirac
Copy link
Contributor

lsirac commented Apr 29, 2019

I see. I'll ask my teammates if they have any ideas.

@aristotaloss
Copy link

aristotaloss commented Jun 7, 2019

I was experiencing this very issue a while ago (about the same time as the issue's date). What fixed it for me was changing this:

		List<AuthUI.IdpConfig> providers = Arrays.asList(
				new AuthUI.IdpConfig.GoogleBuilder().build());

to this:

		GoogleSignInOptions googleOptions = new GoogleSignInOptions.Builder().requestId().requestEmail().requestProfile().build();

		List<AuthUI.IdpConfig> providers = Arrays.asList(
				new AuthUI.IdpConfig.GoogleBuilder().setSignInOptions(googleOptions).build());

It seemed as if I had to explicitly state I needed the email - after that I started getting the email addresses again. Hope it helps someone!

@samtstern
Copy link
Contributor

@Velocity- thanks that's interesting!

The default sign in options are:

public static final GoogleSignInOptions DEFAULT_SIGN_IN =
      new GoogleSignInOptions.Builder().requestId().requestProfile().build();

So there's no requestEmail() there but normally you get the email as part of the default result anyway ... I will have to ask someone about this.

@lsirac can you ask around your team and see if there are known cases where this would make a difference? Maybe we want to add requestEmail() to the FirebaseUI default (as long as it won't cause a scope dialog).

@lsirac
Copy link
Contributor

lsirac commented Jun 7, 2019

I think we need to request the email - doesn't seem to cause a scope dialog.

I just tried using the default options and I don't get an email back.

@samtstern
Copy link
Contributor

The fix for this issue has been released in version 6.2.1

@SaharejazCB
Copy link

Is there any method in react typescript to request for an email from firebase. Currently I am getting null in email parameter.
or any settings required in firebase console.
Please help me as soon as possible

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

No branches or pull requests

5 participants