cordova-plugin-googleplus
cordova-plugin-googleplus copied to clipboard
auth/account-exists-with-different-credential
I'm facing a firebase error auth/account-exists-with-different-credential
when I'm trying to sign in an already existing account(with different auth provider) with facebook. I know this question has been asked many times like here and here but all solutions works for web and I'm stuck with native plugins. I'm using Google Plus and Facebook Connect plugins to sign in on native platforms.
Code:
async continueWithGoogle() {
try {
const googleResponse = await this.googlePlus.login({ webClientId: environment.firebaseConfig.webClientId })
const googleCredential = firebase.default.auth.GoogleAuthProvider.credential(googleResponse.idToken);
const firebaseResponse = await firebase.default.auth().signInWithCredential(googleCredential);
return firebaseResponse;
} catch (error) {
console.log('continue with google: ', error);
}
}
async continueWithFacebook() {
try {
const fbResponse = await this.facebook.login(['email']);
const fbCredential = firebase.default.auth.FacebookAuthProvider.credential(fbResponse.authResponse.accessToken);
const firebaseResponse = await firebase.default.auth().signInWithCredential(fbCredential);
return firebaseResponse;
} catch (error) {
if (error.code === 'auth/account-exists-with-different-credential') {
// What should I do here?
}
console.log('continue with fb: ', error);
}
}
Can I solve this error without using any web method like signInWithRedirect()
or signInWithPopup()
?