Skip to Content
Serverless Web Applications with React and Firebase
book

Serverless Web Applications with React and Firebase

by Mayur Tanna, Harmeet Singh
April 2018
Intermediate to advanced content levelIntermediate to advanced
284 pages
6h 43m
English
Packt Publishing
Content preview from Serverless Web Applications with React and Firebase

Handling account exists errors

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-credentialwhich 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') ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Building Web Applications with Firebase

Building Web Applications with Firebase

Gareth Brown
React Native in Action

React Native in Action

nader dabit, Nickie Buckner

Publisher Resources

ISBN: 9781788477413Supplemental Content