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

Firebase Auth - No Provider Data on Android #181

Closed
Queskr opened this issue Jun 8, 2016 · 6 comments
Closed

Firebase Auth - No Provider Data on Android #181

Queskr opened this issue Jun 8, 2016 · 6 comments

Comments

@Queskr
Copy link

Queskr commented Jun 8, 2016

Hi,

I've upgraded to the 9.0.2 SDK version following the solved auth problem on Android devices. My FirebaseUI-Android package version is 0.4.0 and my device's Google Play Services version is 9.0.83.

Following the fix, my app does authenticate, but alas it does not populate any provider data automatically (see snapshort below), nor does it provide it when called via getProviderData().

snapshot

When getProviderData().toString() is called, I get:
com.google.android.gms.internal.zzadf@3a3aa0b
com.google.android.gms.internal.zzadf@a00f0e8

It does give the provider itself when getProviders().toString() is called (e.g. "google.com").

Thanks,
Yohay

@tikurahul
Copy link

FirebaseUser#getProviderData returns a list of UserInfo.

Can you try calling methods on the instance of UserInfo that you get back ? Also bear in mind that some of the fields in UserInfo are nullable, and dependent on the permissions associated to the underlying idToken or accessToken used to sign in.

You can also try logging in with other providers.

@Queskr
Copy link
Author

Queskr commented Jun 11, 2016

OK, there's some progress :)

I ran the below:
FirebaseUser logged_user = FirebaseAuth.getInstance().getCurrentUser();
Log.d("Queskr", "UserInfo name: "+logged_user.getDisplayName());
Log.d("Queskr", "UserInfo email: "+logged_user.getEmail());
Log.d("Queskr", "UserInfo photo: "+logged_user.getPhotoUrl());
Log.d("Queskr", "UserInfo ProviderData: "+logged_user.getProviderData().toString());

For both Google and FB login, I get the display name and the photo URL, but for some reason I don't get the email (which is most important to me).

I've also ran through the list of UserInfo provided by getProviderData and it shows the same thing (name is available, as well as photo url, but no email).

You wrote that some details are dependent on the idToken and accessToken - does this apply to email as well? how can I influence the tokens?

Thanks!

@jasoncheng
Copy link

jasoncheng commented Jun 11, 2016

@Queskr I spent two days on this, let me share my experience, hope can help :)

Base on firebase sdk 9.0.0 or 9.0.2

It's not FirebaseUI-Android project issue.
It's all about new config on firebase new console -> auth -> enable/disable unique email for multi accounts.

For legacy firebase.com, they use UID like "google:12321323" or "facebook:2312312332", so we can create same email with different accounts from different provider.

For new firebase console:

  • If you enable unique email address, new firebase will automatic generate UID like "7qDrrlmAnQOSeQD4EsnIYdSOpe13", and you can get email from FirebaseUser.getEmail without any problem.
  • If you enable legacy behavior, then you won't be able get email from FirebaseUser.getEmail, but you still can get user email through using AccessToken(fb) or GoogleSignInAccount object (google)

ref

@Queskr
Copy link
Author

Queskr commented Jun 11, 2016

Thanks Jason, it worked!

I needed to enabe unique email and delete all previously defined users, but now it works :)

@Queskr Queskr closed this as completed Jun 11, 2016
@davidgcalle
Copy link

@jasoncheng Hi, could u care to specify how get the user email through AccesToken and GoogleSignInAccount, need to use other libraries?

@xiaofanwu
Copy link

cordovaoath is a good library :)

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

5 participants