Home > Enterprise >  firebase auth in valid authentication error
firebase auth in valid authentication error

Time:10-18

facing the error "[firebase_auth/invalid-verification-is]" while trying to achieve Firebase phone auth in my flutter Application.

The web version of the app is working fine, but the mobile app is throwing error.

SDK version for flutter is: 3.3.2

CodePudding user response:

Android:

  1. If you haven't already set your app's SHA-1 hash in the Firebase console, do so../gradlew signingReport.
  2. To use phone number authentication, Firebase must be able to verify that phone number sign-in requests are coming from your app. There are two ways Firebase Authentication accomplishes this

iOS:

  1. In Xcode, enable push notifications for your project
  2. ensure your APNs authentication key is configured with Firebase Cloud Messaging (FCM) and Start receiving silent notifications.

CodePudding user response:

I follow this link [https://firebase.google.com/docs/auth/flutter/phone-auth][1] to authenticate from native device  i configure all configuration of this but still showing the error "[firebase_auth/invalid-verification-is] The verification ID used to create the phone auth credential is invalid" in native device not on web browser.
My firebase code for sending code on phone number is:
await FirebaseAuth.instance.verifyPhoneNumber(
                        phoneNumber: ' 92$phone',
                        timeout: const Duration(seconds: 60),
                        verificationCompleted:
                            (PhoneAuthCredential credential) {},
                        verificationFailed: (FirebaseAuthException e) {},
                        codeSent: (String verificationId, int? resendToken) {
                          MyPhone.verify = verificationId;
                          Navigator.pushNamed(context, 'otp');
                        },
                        codeAutoRetrievalTimeout: (String verificationId) {},
                      );
and for verification is following code
PhoneAuthCredential credential =
                            PhoneAuthProvider.credential(
                                verificationId: MyPhone.verify, smsCode: code);
                        await FirebaseAuth.instance
                            .signInWithCredential(credential);
Kindly someone help me out to resolve error.
  • Related