I'm implementing facebook login with firebase for my application. The objective is to develop a logic that the user can login with email/password provider or facebook provider. As i started developing, i found two ways to do what i want:
1 - Link facebook to email/password provider:
- User has to be logged in with email/password to make this happen. Which means, if the user is not logged in, i don't have a reference (current user) to link the facebook provider. User cannot sign up with facebook provider because the email is already being used by another provider (email/password).
2 - Enable multiple accounts with the same email on firebase:
User can sign up with facebook and email/password. But firebase won't register the facebook data for the email/password provider. Which means, when i try to get the email from the current user, i have to specify the provider that have the email attribute (facebook provider). Email/password provider returns an empty email
final String email = firebaseUser.getProviderData().get(1).getEmail();
Conclusion
- The first way won't work for me. User may not be logged in all the time. He may want to login in different ways. I don't want the user to insert his password for email/password provider just to link to his facebook provider.
- If i choose the second way, i can't find a way to update the email attribute for email/password provider. And it wouldn't be a good practice to always check what providers the user have, just to specify which provider to get the email from.
Is there something i'm missing? I tried using updateEmail() when user signs up with facebook but it just updates the email attribute for facebook provider. Do i really have to make the user insert his password to create a link between the two providers?