Reputation: 1586
After signing in through Google and logging the data pulled from the FirebaseAuth user, this is how Firebase has you draw a user's account information:
To get the profile information retrieved from the sign-in providers linked to a user, use the getProviderData method.
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
if (user != null) {
for (UserInfo profile : user.getProviderData()) {
// Id of the provider (ex: google.com)
String providerId = profile.getProviderId();
// UID specific to the provider
String uid = profile.getUid();
// Name, email address, and profile photo Url
String name = profile.getDisplayName();
String email = profile.getEmail();
Uri photoUrl = profile.getPhotoUrl();
};
}
When I log the information pulled from each profile
I get the following couple incomplete data sets:
06-08 12:48:12.851 14400-14400/com.example.app D/MainActivity: providerId: firebase, uid: 1***************2, name: null, email: d**********[email protected], url: null
06-08 12:48:12.851 14400-14400/com.example.app D/MainActivity: providerId: google.com, uid: 1************5, name: D*******y, email: null, url: https://lh4.googleusercontent.com/.../photo.jpg
Is there a standard means of combining user information and storing it as a more accessible data set? FirebaseAuth (at least in this example) doesn't seem to be the most clean-cut way to retrieve user information at runtime.
Upvotes: 0
Views: 361
Reputation: 30798
There is no other way to get providerData for a currentUser. I assume you prefer to lookup data by some key such as providerId instead of traversing that list. You can always duplicate this data in realtime database using structure that you prefer such as a key/value map.
Upvotes: 1