1
votes

I need to determine which auth provider/providers are user currently logged into with a particular email . It will be very great if someone provides me with the complete method for fb,google,twitter,github and email method .

I cant find anywhere on internet or Firebase docs the proper code to determine it .This is my code if its of any help guyz.

 mAuth.fetchProvidersForEmail(email[0]).addOnCompleteListener(new OnCompleteListener<ProviderQueryResult>() {
     @Override
     public void onComplete(@NonNull Task<ProviderQueryResult> task) {
         if (task.isSuccessful()) {

           //What to do ??                                                    }
     }
 });

Thanks in advance.

2

2 Answers

1
votes

Inside onComplete(), you can call task.getResult() to get back ProviderQueryResult, which contains the list of Auth providers used by that user.

0
votes

If the user is logged in you can use the following code to get the provider:

FirebaseUser firebaseUser = FirebaseAuth.getInstance().getCurrentUser();
String providerId = firebaseUser.getProviderData().get(1).getProviderId();