Firebase Authentication, Signin with Provider without auto registration

My mobile app (React Native) uses Firebase Authentication (via react-native-firebase) and has options to login with

  • email/password
  • Apple ID
  • Google
  • Facebook

I would like that when the user try to use Apple, Google, or Facebook the procedure will be like

  1. Use the corresponding SDK to authen with Apple, Google, or Facebook and get the token
  2. Authen with Firebase, e.g. auth().signInWithCredential(auth.FacebookAuthProvider.credential(token)).
  3. If can login successfully, go ahead.
  4. If error occurs with code auth/account-exists-with-different-credential, inform the user that they have registered with another method.
  5. If no use exists, go to the registration screen, auto-fill the registration from with as much information as we can get from the provider.

Problem

I cannot do the step 5. because Firebase will authomatically create a user record and not tell me that the user haven't registered.

My first solution around this problem is to get email address from the provider and use auth().fetchSignInMethodsForEmail(email) to check if the user exists or not. But a Facebook account does not always have an email. (The SDK react-native-fbsdk-nex doesn't even return the email actually)

Is it possible to tell if a user exists in Firebase Authentication given only the idToken/accessToken from the provider?

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum