How to Link Multiple Auth Providers to an Firebase Account?

If you want to manually link a google and email/pass account to existing facebook only firebase user, you can do the following: First, the user should be signed in to Facebook. Link the google user:

var provider = new firebase.auth.GoogleAuthProvider();
auth.currentUser.linkWithPopup(provider);

Then link the email/pass account:

auth.currentUser.linkWithCredential(firebase.auth.EmailAuthProvider.credential(auth.currentUser.email, 'password'))

All these accounts to be linked must be new and not already linked.


@bojeil I have read your question and I found the way to log in both Google and Facebook logins having the same email account. First, in the Firebase, you need to allow

"Multiple accounts per email address"

Allow multiple accounts per email address

Now you can log in with both Facebook having "[email protected]" & Google having the same email name as "[email protected]".But you will encounter the email as "null" for the second login having the same email. You can get over the null problem by using the below snippet.

Just use this snippet in on success task from the firebase:

Map profile = task.getResult().getAdditionalUserInfo().getProfile();

Object email = profile.get("email"); /// Obtaining the email from the use though we use same email form facebook and Google log in accounts.

By this way, you can log in into both Facebook and Google logins using the same email.

I hope you got your doubt cleared with this info. Can you please get back to me if this suits your question?.

Thank you.