Is there a way to link Expo facebook login and firebase email/password login, so duplicate users are not created?
– For example if my facebook email account is test@test.com, I don’t want to create a firebase email/password account of test@test.com.
I figured it out, first login users using expo’s Facebook.logInWithReadPermissionsAsync()
.
After you get the user’s Facebook access token, use it to build a Credential object and then sign in the user with the credential:
For more help go to firebase’s link.
const doFacebookLogin = async dispatch => {
const { type, token } = await Facebook.logInWithReadPermissionsAsync('xxxxxxxx', {
permissions: ['public_profile']
});
const credential = firebase.auth.FacebookAuthProvider.credential(token);
await firebase.auth().signInWithCredential(credential);
dispatch({ type: FACEBOOK_LOGIN_SUCCESS, payload: token });
};