April 2018
Intermediate to advanced
284 pages
6h 43m
English
Consider that we have enabled the One account per email address option in firebase settings. As you can see in the preceding screenshot when we tried to log in with the provider (Google) with an email that already exists in firebase with a different provider (such as Facebook), it throws the mentioned error—auth/account-exists-with-different-credential—which we can see in the preceding screenshot. To handle this error and complete the sign into the selected provider, the user has to sign in first to the existing provider (Facebook) and then link to the former AuthCredential (with Google ID token). After rewriting the authWithFacebook() method, this is how our code looks:
if (error.code === 'auth/account-exists-with-different-credential') ...