簡體   English   中英

Flutter Firebase Android 上的電話驗證錯誤

[英]Flutter Firebase Phone Authentication error on Android

我想用 Firebase Auth 驗證電話號碼,但它給出了以下錯誤,

注意:我的 sha1 和 sha256 密鑰已附上。 當我手動將電話號碼添加到 firebase 時,它可以工作。 在 iOS 設備上運行順暢。

[GetAuthDomainTask] 獲取項目配置時出錯。

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

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

我有同樣的錯誤,因為我通過 vscode 終端生成了我的 sha1 證書,如果你想要電話身份驗證,這很糟糕。 所以我修復了

  1. 通過 android 工作室打開我的 android 文件夾
  2. 點擊.android/app/build.gradle
  3. 選擇 gradle 查看左側 android 工作室
  4. 選擇android>task>signReport
  5. 等待一段時間,你會得到真正的沙! 證書
  6. 在那里復制並過去 firebase 項目。

如果這些不起作用,請檢查

  1. 如果您從 firebase auth 啟用電話驗證
  2. 然后啟用android deviceCheck Api

將以下依賴項添加到您的 build.gradle 文件中

實現 'androidx.browser:browser:1.3.0'

@Ufuk Zimmerman 可以通過android>task>signReport為您創建證書以進行調試,但是當您創建簽名的.apk時,您需要使用密鑰庫(.jks)文件,並且您需要通過我認為的相同密鑰庫創建 SHA使用命令獲取 SHA 的最佳方式。

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

例子

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

檢查 app/build.gradle 包含以下用於調試和發布的代碼

在此處輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM