-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐛 [firebase_auth] signInWithEmailAndPassword returns error code "unknown" #10966
Comments
Hi @jayjay911, how is your project setup on firebase? And can you provide a complete minimal reproducible code sample so that we can investigate this? |
Not sure what you need to know specifically about the Firebase project, there's a registered web app and I'm using the same configuration which has been working fine for over a year. Email and password sign in is enabled, along with SMS MFA. The only change was client side ie upgrading Flutter to 3.10.0 and all the Firebase dependencies to support Dart 3. Then suddenly my Firebase sign in stopped working as it should. Is the following sample of code enough or do you need a github project? Added only the following dependencies to pubspec.yaml: firebase_core: any Minimal Reproducible CodeClick To Expand
|
Downgrading Flutter back to version 3.7.12 and Dart back to version 2.19.6 immediately resolved the issue, error code is set and not "unknown" and the FirebaseAuthMultiFactorException is thrown properly. So issue only occurs when I upgrade to Flutter 3.10.0 and Dart 3. |
Thanks for the details. I can reproduce the error code being returned as unknown using the sample provided above on stable 3.10.0 but on stable 3.7.12, the error code is properly stated. I was only able to reproduce this on the web. My firebase project was not set up to use SMS MFA so the Labeling for further investigation Running on flutter 3.7.12
Running on flutter 3.10.0
|
any updates on this? |
This also affecting my app as well. Any updates would be great as to what is happening with this. |
Until this is fixed, here's a regex that will extract the code of a FirebaseAuthException from the exception message: Note: This fix is temporary; as soon as a patch is deployed, we should use it. String parseFirebaseAuthExceptionMessage({String plugin = "auth", required String? input}) {
if (input == null) {
return "unknown";
}
// https://regexr.com/7en3h
String regexPattern = r'(?<=\(' + plugin + r'/)(.*?)(?=\)\.)';
RegExp regExp = RegExp(regexPattern);
Match? match = regExp.firstMatch(input);
if (match != null) {
return match.group(0)!;
}
return "unknown";
} Usage: try {
// operation that might throw a FirebaseAuthException
} on FirebaseAuthException catch (e) {
// change the plugin argument if needed
// final code = parseFirebaseAuthExceptionMessage(input: e.message, plugin: "other");
final code = parseFirebaseAuthExceptionMessage(input: e.message);
if (code == "user-not-found") {
// handle exception
}
} |
Yeah I'm getting the same issue. |
Could anybody tell me how to fix it now in the latest flutter version? |
Having the same problem here, all throw exception are coming unknown. |
As a temporary workaround I just downgraded Flutter sdk to 3.7.9. Works fine. Hope the issue would be fix for the latest version at some point. |
This is impacting my project as well. Running From my debugging session: DEBUG from VSC:
|
We've also had big problems with Firebase Auth being compatible with the latest version of Flutter. We do not understand why a Google Flutter release has been made and with the Google Firebase suite being left behind and not compatible, and with no resolution in weeks... Is Firebase not important as part of Google's strategy around Flutter... It would also be good if the Flutter Firebase suite was written purely in dart, end-to-end as the warning messages in the terminal due to Firebase Core is a really bad developer experience, with hours of research/resolution needed to fix - to such a degree that Andrea has very kindly written a long article to help people with this https://codewithandrea.com/articles/flutter-firebase-flutterfire-cli/ |
I have the same issue. |
I also have the same issue, but the regex by @jubnl helps a lot. And it is only in debug mode, when I host my flutter web page on firebase or github, it works correctly, so I set a conditional for choose between regex and the correct form if I'm on release mode or not |
is that because ou must update the phone number for the user first ? |
hello, i am trying to do this exact thing in flutter flow (creating an authentication custom action ) and it throws the same kind of errors for me too, is there ant work around? |
There was a bug where the signInWithEmailAndPassword method in firebase_auth package was returning an error code as "unknown". This issue was reported in the GitHub repository of FlutterFire: firebase/flutterfire/issues/10966. To address this issue, a temporary fix has been implemented by using the parseFirebaseAuthExceptionMessage function. This function uses a regex pattern to extract the error code from the FirebaseAuthException's exception message. The fix ensures that the actual error code is properly extracted and handled, providing more accurate error information during the sign-in process. Note: This is a temporary fix until the underlying issue is resolved in the firebase_auth package.
The signIn function has been updated to handle Firebase authentication errors more effectively. This refactor addresses a bug where signInWithEmailAndPassword was returning an error code as "unknown" (GitHub issue: firebase/flutterfire/issues/10966). To address this issue, a temporary fix has been implemented using the parseFirebaseAuthExceptionMessage function. This function extracts the error code from the FirebaseAuthException's exception message using a regular expression. The new code includes a switch statement to handle specific error codes such as "wrong-password", "user-not-found", "user-disabled", "too-many-requests", and "network-request-failed". Each error code is associated with a customDialogBox that displays an appropriate error message. In case an unknown error code is encountered, the customDialogBox displays the code itself temporarily, along with the error message. Additionally, a catch block has been added to handle any other errors that may occur during the sign-in process. These changes improve the error handling and provide more informative error messages to the user in case of authentication failures.
is there any updates on this bug? also encountered this error. I also need the FirebaseAuthMultiFactorExceptionto be able to access the resolver. |
i tried updating my flutter version and firebas euth to latest versions, the error still occurs. Hopefully it would be fixed on next updates of firebase auth plugin. |
I am stuck on this error. Can't proceed to completeley implement Firebase MFA. |
if i may ask, how can we apply the fix? will this fix be included in the next updates of firebase_auth? |
@anjogithub - will be out in the next release at some point today 👍 |
i got the same problem, i changed it to get_user_by_email, i can get uid, but my app can't use authentication |
Bug report
Describe the bug
I am using Flutter Web and running in Chrome.
After upgrading to Flutter 3.10.0 and all my firebase dependencies I started getting unusual behaviour when attempting to sign into firebase with email and password.
Instead of throwing a FirebaseAuthMultiFactorException as expected, it throws a FirebaseAuthException with the following message:
An unknown error occurred: FirebaseError: Firebase: Proof of ownership of a second factor is required to complete sign-in. (auth/multi-factor-auth-required).
Error code is:
"unknown"
Error code is always "unknown" even in cases where email/password are incorrect.
Issue persists in a Flutter Demo Project with only firebase dependencies
Steps to reproduce
Steps to reproduce the behavior:
Create a Flutter Demo Project
Add necessary code to initialise FirebaseApp
Add the following to _incrementCounter() :
Expected behavior
I am expecting a FirebaseAuthMultiFactorException where email and password are correct, otherwise a FirebaseAuthException with a code as before.
I need the FirebaseAuthMultiFactorException obviously so I can access the resolver, and I need the code in order to handle incorrect password, user does not exist etc cases.
Additional context
Running Flutter Web version in Chrome on M1 MacBook
Flutter doctor
Run
flutter doctor
and paste the output below:Click To Expand
Flutter dependencies
Run
flutter pub deps -- --style=compact
and paste the output below:Click To Expand
The text was updated successfully, but these errors were encountered: