【发布时间】:2021-02-19 13:01:27
【问题描述】:
我正在尝试实施 Firebase 电话验证。我已在 Firebase 控制台上启用电话验证。我已生成密钥库并将 SHA 签名添加到控制台。
依赖:
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");
},
);
当执行上述块时,收到以下错误。 控制台输出:
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
【问题讨论】:
-
连同错误日志,请添加有关您尝试执行的操作的更多详细信息。从您收到此错误的位置添加代码 sn-p
-
我也面临同样的问题。有什么想法吗?
-
面临同样的问题..
-
同样的问题。似乎与应用程序 Gradle firebase auth library 有关。不过,更新它对我不起作用。
-
您是否将 sha1 添加到 firebase 控制台?
标签: java android firebase flutter authentication