Flutter Firebase Auth Returns invalid-credential, Not wrong-password? Why, and the 4-Step Fix

By · Published 2026-11-22 · Last verified 2026-11-22

Why does Firebase Auth return invalid-credential instead of wrong-password in Flutter?

Because your Firebase project has email enumeration protection turned on. With it on, a failed email-and-password sign-in no longer tells your app whether the email exists, so FlutterFire throws invalid-credential where older code expected user-not-found or wrong-password. Google's Identity Platform docs say the protection is on by default for projects created on or after September 15, 2023, and the firebase_auth API reference now marks user-not-found and wrong-password as deprecated for this reason. GSPTeck is giosaia's indie studio building mobile and web apps with Flutter and Firebase; this guide was checked against the Firebase, Identity Platform and pub.dev docs on 2026-11-22.

Grid of the 4-step Generic Credential Fix for Flutter: log e.code once, map three codes to one neutral message, offer a password reset without confirming the email, and remove sign-in method lookups, with protection on by default since 15 September 2023
The 4-step Generic Credential Fix.

What changed, and which error codes you get now

Short answer: the server returns one generic error for "no such user" and "wrong password", and FlutterFire maps it to invalid-credential. The Identity Platform page says invalid sign-in cases return INVALID_LOGIN_CREDENTIALS, and the pub.dev reference adds that older native SDKs reported invalid-login-credentials instead.

SituationWithout protectionWith protection (default since 2023-09-15)
Email not registereduser-not-foundinvalid-credential
Wrong passwordwrong-passwordinvalid-credential
Malformed emailinvalid-emailinvalid-email (unchanged)
Too many attemptstoo-many-requeststoo-many-requests (unchanged)
Email/password provider offoperation-not-allowedoperation-not-allowed (unchanged)
Sign-up with an email already in useemail already in useStill returned: Identity Platform says invalid sign-up cases continue to return EMAIL_EXISTS

The official Flutter password-auth sample on firebase.google.com still checks user-not-found and wrong-password in its signInWithEmailAndPassword snippet, which is why so much copied code silently stops matching. Those branches never run on a protected project.

The 4-step Generic Credential Fix

The fix is to treat invalid-credential as "email or password is wrong" and stop trying to tell the user which one. Do these four steps in order.

  1. Log the real code once. In on FirebaseAuthException catch (e), print e.code during development. If you see invalid-credential for both a missing user and a bad password, protection is on.
  2. Map the codes to three messages. invalid-credential, user-not-found and wrong-password all become "Email or password is incorrect." Keep separate messages for invalid-email, user-disabled, too-many-requests and network-request-failed, because those are still specific.
  3. Offer reset without confirming the account. Put a "Forgot password?" link next to the error. Identity Platform says a reset email is sent only if the address exists, with no error telling you either way, so show "If an account exists, we sent a reset link."
  4. Remove any lookup that reveals accounts. If your login screen calls fetchSignInMethodsForEmail to decide between "sign up" and "sign in", replace it with one form that accepts both paths. With protection on, Identity Platform says that method no longer returns the list of sign-in methods.

A minimal mapping looks like this:

String authMessage(FirebaseAuthException e) {
  switch (e.code) {
    case 'invalid-credential':
    case 'user-not-found':   // deprecated, older projects
    case 'wrong-password':   // deprecated, older projects
      return 'Email or password is incorrect.';
    case 'invalid-email':
      return 'That email address is not valid.';
    case 'user-disabled':
      return 'This account has been disabled.';
    case 'too-many-requests':
      return 'Too many attempts. Wait a moment and try again.';
    case 'network-request-failed':
      return 'No connection. Check your network and retry.';
    default:
      return 'Sign-in failed (${e.code}).';
  }
}
Two columns comparing Firebase sign-in errors with email enumeration protection off, which returns user-not-found and wrong-password, and on, which returns invalid-credential for both and no sign-in method list
What email enumeration protection changes.

What else stops working when protection is on

Short answer: account-discovery helpers and unverified email changes. The Identity Platform page lists these behaviours on protected projects, and each one affects Flutter code we see in indie apps:

Should you turn email enumeration protection off?

No, in almost every case. Google recommends leaving it enabled on all projects, because email enumeration helps attackers confirm which addresses have accounts before credential-stuffing or phishing them. The Firebase console still offers the switch under Authentication, Settings, User actions, but turning it off only to get the old error codes back trades your users' privacy for a slightly more specific error message.

The same page suggests extra protection for sign-up endpoints, which still return EMAIL_EXISTS: enable App Check, add reCAPTCHA to sign-up, or prefer providers such as Google Sign-In. Our notes on staging App Check in a Flutter app and hardening Firebase Auth against API key abuse cover both.

Four-step flow of one Flutter login screen: an unknown email and a wrong password both return invalid-credential, both show the same message, and a reset link is sent only if the account exists
Two failures, one neutral message.

A worked example: one login screen, two failures

Illustrative scenario, not a real user. A Flutter app created in 2025 has the default protection. Ana types an email she never registered; the app gets invalid-credential. Ben types his real email with an old password; the app also gets invalid-credential. With the mapping above, both see "Email or password is incorrect" and a "Forgot password?" link. Ben taps it and receives a reset email; Ana taps it and receives nothing, and the screen shows the same neutral confirmation to both. Nobody watching the screen learns whether Ana's address has an account.

If the same code shows user-not-found on one device and invalid-credential on another, check which Firebase project each build points to. A debug build wired to an older project, a release build wired to a newer one, or a mixed setup like the ones in why a Flutter app works in debug but not in release explains the difference.

FAQ

Is invalid-credential a bug in firebase_auth?

No. The firebase_auth API reference documents it as the code for an incorrect email or password on projects with email enumeration protection, which replaces user-not-found and wrong-password so the app cannot reveal whether an account exists.

Why do I still see user-not-found on one project?

That project probably has email enumeration protection turned off. Identity Platform says it is not automatically enabled on projects created before September 15, 2023, so older projects keep the specific codes until someone turns it on.

How can I tell the user they have no account?

On a protected project you should not. Show one neutral message for a wrong email or password, offer a password reset, and offer sign-up on the same screen, so the response is the same whether or not the address is registered.

Does this affect Google or Apple sign-in?

The generic error replaces the email-and-password sign-in codes. Federated sign-in still has its own flows and codes, such as account-exists-with-different-credential when an email already belongs to another provider.

Sources

More Flutter and Firebase fixes from the same studio are on the GSPTeck apps and official links page and the GSPTeck homepage.

Vertical Pinterest graphic with five points for handling invalid-credential instead of wrong-password in Flutter Firebase Auth
Pinterest pin: invalid-credential in Flutter.