We're having real problems trying to resolve this and so hoping for some Firebase assistance / those that have solved the same problem.
The app is React Native (0.43.2) and using Firebase JS API (latest)
We provide Facebook and Google auth. Works fine.
BUT, if a user:
- signs in with Facebook (is ok)
- later, signs in with Google (is also fine)
- later, tries to sign in with Facebook - BOOM! not so fine and Firebase returns this error:
auth/account-exists-with-different-credential
From reading docs and a few posts on SO, we thought the following was correct but clearly not as we're getting the same auth error back.
...error returned by Firebase auth after trying Facebook login...
const email = error.email;
const pendingCred = error.credential;
firebase.auth().fetchProvidersForEmail(email)
.then(providers => {
//providers returns this array -> ["google.com"]
firebase.auth().signInWithCredential(pendingCred)
.then(result => {
result.user.link(pendingCred)
})
.catch(error => log(error))
The call to signInWithCredential is throwing the same error auth/account-exists-with-different-credential
.
Can anyone help point out what we are doing wrong with this implementation? Greatly appreciated.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…