Naresh
Naresh

Reputation: 25823

What is the full list of provider id's for firebase.UserInfo.providerId?

The docs say

For example, 'facebook.com', or 'google.com'.

However, is the exhaustive list available somewhere and can I depend on it? Can these id's ever be a variation, like 'facebook' or 'google' (without the .com)?

Context: I am trying to figure out if the signed in user has a social login. So I want to loop through currentUser.providerData and match it against a known list of providerIds.

Upvotes: 38

Views: 16688

Answers (6)

Doruk Okbay
Doruk Okbay

Reputation: 138

For anyone coming to this page for info on Google Play id, it's:

"playgames.google.com"

Upvotes: 0

Yash
Yash

Reputation: 3576

Simplest way is to check the providers list in the rules tab: Auth providers list

Upvotes: 5

Victor Dias
Victor Dias

Reputation: 645

Strange is MicrosoftAuthProvider is missing on js SDK (but works) and available on unity SDK

Upvotes: 0

thilina Kj
thilina Kj

Reputation: 1413

    import com.google.firebase.auth.*


    val user = FirebaseAuth.getInstance().currentUser
    user?.let {
        for (profile in it.providerData) {
            when(profile.providerId){
                GoogleAuthProvider.PROVIDER_ID -> {

                }
                EmailAuthProvider.PROVIDER_ID -> {

                }
                PhoneAuthProvider.PROVIDER_ID -> {

                }
                FacebookAuthProvider.PROVIDER_ID -> {

                }
                TwitterAuthProvider.PROVIDER_ID -> {

                }
                GithubAuthProvider.PROVIDER_ID -> {

                }
            }
        }
    }

Here are Firebase SDK provider classes.

Upvotes: 2

Pat Needham
Pat Needham

Reputation: 5638

From the Sign-In Method sub-tab within Authentication found on the Firebase console for any project, you can see a list of available Sign-in providers:

enter image description here

Firebase's documentation doesn't seem to be even across different platforms, but for the iOS Reference docs there is a list of FirebaseAuth Constants that match up with those from the project console dashboard, with the exception of Anonymous provider:

  1. EmailAuthProviderID
  2. PhoneAuthProviderID
  3. GoogleAuthProviderID
  4. FacebookAuthProviderID
  5. TwitterAuthProviderID
  6. GitHubAuthProviderID
  7. AppleAuthProviderID
  8. YahooAuthProviderID
  9. MicrosoftAuthProviderID

After making a new iOS project from scratch and adding this code to the didFinishLaunchingWithOptions method:

FirebaseApp.configure()
print("EmailAuthProviderID: " + EmailAuthProviderID)
print("PhoneAuthProviderID: " + PhoneAuthProviderID)
print("GoogleAuthProviderID: " + GoogleAuthProviderID)
print("FacebookAuthProviderID: " + FacebookAuthProviderID)
print("TwitterAuthProviderID: " + TwitterAuthProviderID)
print("GitHubAuthProviderID: " + GitHubAuthProviderID)
print("AppleAuthProviderID: " + AppleAuthProviderID)
print("YahooAuthProviderID: " + YahooAuthProviderID)
print("MicrosoftAuthProviderID: " + MicrosoftAuthProviderID)

The output I get is:

EmailAuthProviderID: password
PhoneAuthProviderID: phone
GoogleAuthProviderID: google.com
FacebookAuthProviderID: facebook.com
TwitterAuthProviderID: twitter.com
GitHubAuthProviderID: github.com
AppleAuthProviderID: apple.com
YahooAuthProviderID: yahoo.com
MicrosoftAuthProviderID: hotmail.com

Upvotes: 83

Ali Baalbaki
Ali Baalbaki

Reputation: 41

you can use this method to identify the Type of Provider :

    private String checkType(String s) {
    String type;

    switch (s) {
        case "password":
            type = "EmailAuthProviderID";
            break;
        case "phone":
            type = "PhoneAuthProviderID";
            break;
        case "google.com":
            type = "GoogleAuthProviderID";
            break;
        case "facebook.com":
            type = "FacebookAuthProviderID";
            break;
        case "twitter.com":
            type = "TwitterAuthProviderID";
            break;
        case "github.com":
            type = "GitHubAuthProviderID";
            break;

    }


}

Upvotes: 4

Related Questions