0
votes

So I notice in the Firebase console, there's a panel called "Authentication" that contains a list of users. Every user has four pieces of information: Identifier, Provider, Created, Signed in, and User UID.

I'm wondering if there's a way you can programmatically access this information, while the user isn't signed in.

Thanks.

2

2 Answers

0
votes

Yes you can access those values using several methods. In order to get the provider, i suggert you using this code:

FirebaseUser firebaseUser = firebaseAuth.getCurrentUser();
if (firebaseUser != null) {
    for (UserInfo userInfo : firebaseUser.getProviderData()) {
        if (userInfo.getProviderId().equals("facebook.com")) {
            Log.d("TAG", "User is signed in with Facebook");
        }

        if (userInfo.getProviderId().equals("google.com")) {
            Log.d("TAG", "User is signed in with Google");
        }
    }
}

There also other methods which are very useful: getUid(), getDisplayName(), getEmail(), getPhoneNumber() and so on. please take a look at official documentation.

As a conclusion for this question, there's no way in which you can call another method to get the email address of an user. What can you do in stead, you can create a users section in your Firebase database, store all data you need and than just query it.

Hope it helps.

0
votes

I have found in documentation something like this: Documentation about admin.auth().listUsers(...)

https://firebase.google.com/docs/auth/admin/manage-users#list_all_users

admin.auth().listUsers(maxResults, pageToken);