Home > OS >  Firebase login with email giving "auth/wrong-password" for a Google account
Firebase login with email giving "auth/wrong-password" for a Google account

Time:06-27

I'm using Firebase Auth, with email and Google providers enabled.

I have an account that's registered with a Google provider: "[email protected]". There is no password associated with it, since it's a Google account.

If a user tries to use email/password to log in with "[email protected]", using signInWithEmailAndPassword, it results in a auth/wrong-password error code (no matter what password is entered, of course).

This seems strange to me, as I would expect some error like "auth/different-provider", so I could nudge the user towards logging in correctly.

Is there a way where I can tell that this operation failed due to using a different provider? Or is it opaque from the perspective of the client?

CodePudding user response:

firebaser here

The idea of the Firebase API is that you ask the user for their email address first (since that is the primary identifier) and then (if your app allows signing in with different provider(s)) you call fetchSignInMethodsForEmail to determine with which provider(s) that email address can sign in.

If you follow this flow, the code will only show the Google sign-in for the user, since that's the only provider fetchSignInMethodsForEmail will return.

You can of course also use the API within your current flow to detect the mismatch yourself and show an error message, but the flow above is what the API is designed for and what (for example) the Firebase-UI libraries implement.

  • Related