Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

auth/account-exists-with-different-credential #736

Open
mayankkataria opened this issue Apr 18, 2021 · 0 comments
Open

auth/account-exists-with-different-credential #736

mayankkataria opened this issue Apr 18, 2021 · 0 comments

Comments

@mayankkataria
Copy link

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()?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant