Search code examples
flutterfirebase-authentication

Why does Flutter FirebaseAuth signInWithEmailAndPassword throw an invalid-credential exception?


I have the code below in my Flutter app. I am calling it with known good email and password values, but I am hitting the 'invalid-credential' case. I have firebase_auth: ^4.16.0 in my pubspec.yaml file.

try {
  await FirebaseAuth.instance
    .signInWithEmailAndPassword(email: email, password: password);
} on FirebaseAuthException catch (exception) {
  switch (exception.code) {
    case 'invalid-credential':

rest of catch block...

I even tried disabling email enumeration protection, based on a comment here: Firebase issue thread, but that didn't fix the problem. I'm happy to provide any other necessary information.

The user was created by successfully calling

FirebaseAuth.instance.createUserWithEmailAndPassword

The issue happens with several accounts.


Solution

  • With the kind help of @Doug Stevenson and @FaBotch, I found a simple mistake in my createUserWithEmailAndPassword call. Thanks for your time and patience.