Reputation: 213
I've been trying to setup an application that supports 3 types of Authentication: - Email / password - Google (OAuth) - Facebook (OAuth)
In Firebase > Authentication > Sign-in methods, I've enabled the 3 options mentioned above. In Firebase > Authentication > Advanced, I have the following set: "Prevent creation of multiple accounts with the same email address"
Just FYI, the password I use in my app to create an account with [Email/password] is different from my Google account, which is also different from my Facebook account (3 separate passwords - very real world scenario)
I want a user to Sign up with whatever provider they want to and then later on, link any other available sign-in / authentication options.
I can manage to properly setup [Email / Password] or the OAuth providers (Google and Facebook). But, when I try and integrate all 3 together, all hell breaks loose. Some noted errors:
Scenario A)
Scenario B)
I know there have been some updates / changes recently within Firebase, maybe the documentation / examples I checked weren't up-to-date. Has anyone successfully been able to [Email/password] authentication with OAuth providers as well? Can anyone provide a good example online or some recent documentation I can take a look at?
Btw, running code in Angular5 if that helps. Thanks in advance for any help.
JB
Upvotes: 0
Views: 825
Reputation: 30798
Scenario A) happens because the email/password is unverified. The account is unlinked to prevent hijacking. For example I can claim another person's google email and create an email/password account. The owner of that Google account will then try to login to that account. I should lose access to it. To solve, try verifying the email after the email/password account is created. The verified account will not be unlinked.
Scenario B) This does not happen because of the passwords. Firebase doesn't have access to your Facebook or Google password. Are you sure you linking the account correctly? When you try to login with Facebook using the same email as existing email/password, you will get an error that the credential already exists (the error also returns the Facebook credential), you will need to first sign in to the existing email/password account and then link the Facebook credential to that account.
Upvotes: 3