1

So we're running into something we dont really understand: When we try to login to facebook, using an account that is already linked (has both Google and Facebook providers), we get the error: auth/account-exists-with-different-credential'. This is using v4.12.1 of the JS SDK.

Code

async loginFacebook() {
   const facebookProvider = this.getFacebookProvider();

   await this.auth.signInWithRedirect(facebookProvider);

   // The error is thrown here, and then caught by the .catch(), which is unexpected, because as mentioned, the accounts are already linked.
   const result = await this.afAuth.auth.getRedirectResult()
     .catch(this.linkIfDuplicateAccount);

   // ... rest of code left out, as its irrelevant.
}

Now before the accounts were linked, we'd expect the above error to be thrown; but after they are linked!? Why does that happen?

A bit of bonus info. Our initial implementation was based on Firebase JS API auth - account-exists-with-different-credential and it seemed to work, only recently did we notice the above.

Also, when we log out a user, we purge the local indexdb database, as our devices can be shared between multiple users, but I don't see that being the problem. Mentioned anyway.

DarkNeuron
  • 7,981
  • 2
  • 43
  • 48
  • You should be getting this error if the accounts are not linked. You code snippet looks incorrect. If you have an existing Google account and then login with Facebook using the same email, you will get that error. You are expected to login to the existing Google account first and then link the Facebook account to that account. Afterwards, you will be able to sign in the user with either provider. – bojeil Apr 16 '18 at 04:44
  • But the use case is: The account already has both providers (Google and Facebook); the user is logged out, and then tries to login via facebook. The above error is thrown. – DarkNeuron Apr 16 '18 at 07:55

0 Answers0