Error while geting Firebase Phone Auth OTP

一个人想着一个人 提交于 2020-12-30 06:16:30

问题


I am trying to implement Firebase Phone Verification. I have enabled phone verification on firebase console. I have generated keystore and added the SHA signatures to the console.

dependencies:

dependencies {
    def multidex_version = "2.0.1"
    implementation platform('com.google.firebase:firebase-bom:26.0.0')
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.google.firebase:firebase-analytics'
    implementation "androidx.multidex:multidex:$multidex_version"
    implementation 'com.google.firebase:firebase-auth'
    implementation 'com.google.firebase:firebase-core'
    implementation 'com.google.firebase:firebase-analytics'
    implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'

}

phone_verification.dart

                await FirebaseAuth.instance.verifyPhoneNumber(
                  phoneNumber: '+1234567890',

                  verificationCompleted: (PhoneAuthCredential credential) {
                    print('verificationCompleted');
                    
                  },
                  verificationFailed: (FirebaseAuthException e) {
                    print('verificationFailed');
                    if (e.code == 'invalid-phone-number') {
                      print('The provided phone number is not valid.');
                    }
                    else {
                      print('Some error occoured: $e');
                    }
                  },
                  codeSent: (String verificationId, int resendToken) async {
                    print('codeSent');

                    // Update the UI - wait for the user to enter the SMS code
                    String smsCode = '123456';

                    // Create a PhoneAuthCredential with the code
                    PhoneAuthCredential phoneAuthCredential = PhoneAuthProvider.credential(verificationId: verificationId, smsCode: smsCode);
                  
                  },
                  timeout: const Duration(seconds: 60),
                  codeAutoRetrievalTimeout: (String verificationId) {
                    print("Timeout: $verificationId");
                  },
                );

When the above block is executed following error is received. Console Output:

E/FirebaseAuth: [GetAuthDomainTask] Error getting project config. Failed with {
      "error": {
        "code": 400,
        "message": "INVALID_CERT_HASH",
        "errors": [
          {
            "message": "INVALID_CERT_HASH",
            "domain": "global",
            "reason": "invalid"
          }
        ]
      }
    }
     400
V/FA: Recording user engagement, ms: 1165
E/zza: Failed to get reCAPTCHA token - calling backend without app verification

回答1:


Enable Phone option in the Firebase Console under Authentication




回答2:


@CubeRootX and @user13864571

Your problem related to SHA1 and SHA256 keys. You have to add them to authenticate your certs.

Goto

  • Firebase Console of your project
  • Authentication
  • Project Setting (From Setting button near Project Overview)
  • Add fingerprint
  • Add SHA-1 and SHA-256 values of your keystore.

You can get keystores from gradle like this.

./gradlew signingReport

Read this for more information: https://firebase.google.com/docs/auth/android/phone-auth#enable-app-verification



来源:https://stackoverflow.com/questions/64720643/error-while-geting-firebase-phone-auth-otp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!