问题
Here is my scenario, if user sign in with google provider first in my web application following after sometimes the same user may try to login in using facebook provider, now if the user's facebook provider email id matches with the previous google provider mail id in firebase, it will throw error like "account-exists-with-different-credential" in this case firebase will give us the facebook provider email id and instructed us to get the "Asks the user his password." what password will I ask them, if user have to enter the Gmail password will user enter their Gmail password in third party's site
回答1:
In your case, you will also get an email and credential object(facebook credential) in the auth/account-exists-with-different-credential error thrown (error.credential and error.email). You then can call
auth.fetchProvidersForEmail(error.email)
to get the list of existing providers that correspond to that email. In this case you will get an array ['google.com']. Using one of these providers, you sign in the user to that provider.
auth.signInWithPopup(new firebase.auth.GoogleAuthProvider());
You can also set login-hint: error.email as a custom OAuth parameter on the google provider.
After that user is signed in. You then link the previous facebook credential to that user:
currentUser.link(error.credential);
You will now have that facebook account linked to the existing google account. The next time the user tries to login via facebook, the error won't be thrown again.
来源:https://stackoverflow.com/questions/41583583/what-password-will-i-ask-if-auth-account-exists-with-different-credential-is-thr