简体   繁体   English

Flutter Firebase Android 上的电话验证错误

[英]Flutter Firebase Phone Authentication error on Android

I want to verify the Phone number with Firebase Auth but it gives the following error,我想用 Firebase Auth 验证电话号码,但它给出了以下错误,

Notes: My sha1 and sha256 keys are attached.注意:我的 sha1 和 sha256 密钥已附上。 It works when I manually add the phone number to firebase.当我手动将电话号码添加到 firebase 时,它可以工作。 Works smoothly on iOS devices.在 iOS 设备上运行顺畅。

[GetAuthDomainTask] Error getting project config. [GetAuthDomainTask] 获取项目配置时出错。

{
"error":{
  "code":400,
  "message":"INVALID_CERT_HASH",
  "errors":[
     {
        "message":"INVALID_CERT_HASH",
        "domain":"global",
        "reason":"invalid"
     }
  ]
}
}

output: output:

I/chatty  (10469): uid=10134(com.xxx.xxx) identical 1 line
W/xxx.xxx(10469): Accessing hidden method Lsun/misc/Unsafe;- 
>putInt(Ljava/lang/Object;JI)V (greylist, linking, allowed)
W/System  (10469): Ignoring header X-Firebase-Locale because its value 
was null.
D/EGL_emulation(10469): eglMakeCurrent: 0x7a08b7442b80: ver 3 0 (tinfo 
0x7a08b7299680)
E/FirebaseAuth(10469): [GetAuthDomainTask] Error getting project 
config. Failed with {
E/FirebaseAuth(10469):   "error": {
E/FirebaseAuth(10469):     "code": 400,
E/FirebaseAuth(10469):     "message": "INVALID_CERT_HASH",
E/FirebaseAuth(10469):     "errors": [
E/FirebaseAuth(10469):       {
E/FirebaseAuth(10469):         "message": "INVALID_CERT_HASH",
E/FirebaseAuth(10469):         "domain": "global",
E/FirebaseAuth(10469):         "reason": "invalid"
E/FirebaseAuth(10469):       }
E/FirebaseAuth(10469):     ]
E/FirebaseAuth(10469):   }
E/FirebaseAuth(10469): }
E/FirebaseAuth(10469):  400
E/zzf     (10469): Failed to get reCAPTCHA token - calling backend 
without app verification
D/EGL_emulation(10469): eglMakeCurrent: 0x7a08b7442b80: ver 3 0 (tinfo 
0x7a08b7299680)
W/System  (10469): Ignoring header X-Firebase-Locale because its value 
was null.
E/FirebaseAuth(10469): [SmsRetrieverHelper] SMS verification code 
request failed: unknown status code: 17093 null
I/flutter (10469): exception
I/flutter (10469): [firebase_auth/missing-client-identifier] This 
request is missing a valid app identifier, meaning that neither 
SafetyNet checks nor reCAPTCHA checks succeeded. Please try again, or 
check the logcat for more details.
W/GoogleApiManager(10469): com.google.android.gms.internal.auth-api- 
phone.zzv could not execute call because it requires feature 
(sms_retrieve, 1).
W/GoogleApiAvailability(10469): GMS core API Availability. 
ConnectionResult=2, tag=null
W/GoogleApiAvailability(10469): java.lang.IllegalArgumentException

I have the same error because I generated my sha1 certificate through vscode terminal which is bad if you want phone auth.我有同样的错误,因为我通过 vscode 终端生成了我的 sha1 证书,如果你想要电话身份验证,这很糟糕。 so i fixed by所以我修复了

  1. open my android folder through android studio通过 android 工作室打开我的 android 文件夹
  2. click .android/app/build.gradle点击.android/app/build.gradle
  3. choose gradle view on the left side of the android studio选择 gradle 查看左侧 android 工作室
  4. choose android>task>signReport选择android>task>signReport
  5. wait some time and you will get the real sha!等待一段时间,你会得到真正的沙! certificate证书
  6. there copy and past firebase project.在那里复制并过去 firebase 项目。

if those does'nt work then check如果这些不起作用,请检查

  1. if you enabled phone authenticatin from firebase auth如果您从 firebase auth 启用电话验证
  2. then enable android deviceCheck Api然后启用android deviceCheck Api

Add below dependency to your build.gradle file将以下依赖项添加到您的 build.gradle 文件中

implementation 'androidx.browser:browser:1.3.0'实现 'androidx.browser:browser:1.3.0'

@Ufuk Zimmerman May the creating certificate by android>task>signReport work for you for debug but when you create signed .apk you need to use a keystore (.jks) file and you need to create SHA by the same keystore I think for this the best way to use command to get SHA. @Ufuk Zimmerman 可以通过android>task>signReport为您创建证书以进行调试,但是当您创建签名的.apk时,您需要使用密钥库(.jks)文件,并且您需要通过我认为的相同密钥库创建 SHA使用命令获取 SHA 的最佳方式。

keytool -list -v -keystore {keystore_name_with_complete_path} -alias {alias_name}

example例子

keytool -list -v -keystore C:\Users\name\Desktop\test.jks -alias test

check app/build.gradle contain following code for debug and release检查 app/build.gradle 包含以下用于调试和发布的代码

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM