获取Firebase Phone Auth OTP时出错 [英] Error while geting Firebase Phone Auth OTP
问题描述
我正在尝试实施Firebase电话验证.我已在Firebase控制台上启用电话验证.我已经生成了密钥库,并将SHA签名添加到了控制台.
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 {
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
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
推荐答案
@CubeRootX和@ user13864571
@CubeRootX and @user13864571
您的与SHA1和SHA256密钥有关的问题.您必须添加它们以对您的证书进行身份验证.
Your problem related to SHA1 and SHA256 keys. You have to add them to authenticate your certs.
转到
- 项目的Firebase控制台
- 身份验证
- 项目设置(通过项目概述"附近的设置"按钮)
- 添加指纹
- 添加密钥库的SHA-1和SHA-256值.
您可以像这样从gradle获取密钥库.
You can get keystores from gradle like this.
./gradlew signingReport
./gradlew signingReport
请阅读以下内容以获取更多信息: https://firebase.google.com/docs/auth/android/phone-auth#enable-app-verification
Read this for more information: https://firebase.google.com/docs/auth/android/phone-auth#enable-app-verification
这篇关于获取Firebase Phone Auth OTP时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!