简体   繁体   中英

Flutter Firebase Phone Authentication error on Android

I want to verify the Phone number with Firebase Auth but it gives the following error,

Notes: My sha1 and sha256 keys are attached. It works when I manually add the phone number to firebase. Works smoothly on iOS devices.

[GetAuthDomainTask] Error getting project config.

{
"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

I have the same error because I generated my sha1 certificate through vscode terminal which is bad if you want phone auth. so i fixed by

  1. open my android folder through android studio
  2. click .android/app/build.gradle
  3. choose gradle view on the left side of the android studio
  4. choose android>task>signReport
  5. wait some time and you will get the real sha! certificate
  6. there copy and past firebase project.

if those does'nt work then check

  1. if you enabled phone authenticatin from firebase auth
  2. then enable android deviceCheck Api

Add below dependency to your build.gradle file

implementation '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.

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

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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