There is a well-documented error (or maybe it's better called a 'by-design pattern') that arises involving Firebase Authentication where a user has a pre-existing account associated with Google Sign In, and then they attempt to use Facebook Sign In with the same email address and Firebase throws an error.code of auth/account-exists-with-different-credential
There's an older Q/A here, from Nov 2016: Firebase Overwrites Signin with Google Account
The best-looking solution seems to be here, from May 2017: https://stackoverflow.com/a/44040373/51482
However, the accepted answer from May 2017 doesn't actually work for React Native (the commented out examples refer to JS Web) and there doesn't appear to be any guidance for the best user experience we can provide in this situation using the React Native framework.
Here are a few questions I have where the answers can maybe set expectations for how to solve this problem best:
- Is there a way to link the pre-existing Google and Facebook accounts without the user needing to login an additional time with their Google Sign In?
- Is there a way to use the thrown
error.emailvalue, retrieve the associated Firebase Auth/Google account based on that email, and then link the Google account credential with the Facebookerror.credentialvalue? - A comment for the aforementioned answer says
If you have your own mechanism to get that token, you get it for that Google email user and sign in. Are there any recommended ways to find this mechanism? - Is the only known UX pattern to force the user to read a message about the pre-existing Google account, direct them to login with the Google account, and then push them to link the Facebook account on a different screen?
The Firebase documentation is pretty solid between native iOS, native Android, and Web platforms, but React Native is kind of in-between all of these codebases and I'm trying to fill the gaps for a good user auth experience with this scenario.