I'm getting this error when I try to run my app on emulator.
What I've done:
In fact when I run the app on a real device it runs perfectly and I can login.
This app is not authorized to use Firebase Authentication. Please verify that the correct package name and SHA-1 are configured in the Firebase Console.
com.google.firebase.auth.FirebaseAuthException: This app is not authorized to use Firebase Authentication. Please verifythat the correct package name and SHA-1 are configured in the Firebase Console. [ App validation failed. Is app running on a physical device? ]
at com.google.android.gms.internal.jz.zzK(Unknown Source:239)
at com.google.android.gms.internal.kp.zza(Unknown Source:2)
at com.google.android.gms.internal.kq.run(Unknown Source:37)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
In order to prevent abuse the firebase phone authentication wont work in emulator.
But if you want it for testing purpose then you should add use some testing phone number in firebase console that will work in emulator.
Go to your firebase console -> Authentication -> SIGN-IN Method -> Phone and check the "Phone numbers for testing (optional)" field.
sha1 generation in android studio:
Select Gradle in android studio from right panel
Select Your App
In tasks -> android-> signingReport
Double click signingReport.
You will find the sha1 fingerprint in the "Gradle Console"
add this sha1 fingerprint in firebase console
OK, so it is a documented error. https://github.com/firebase/FirebaseUI-Android/issues/790 and https://github.com/firebase/FirebaseUI-Android/issues/868
in order to prevent abuse you can't user Phone Auth on an emulator.
docs are here: https://firebase.google.com/docs/auth/android/phone-auth#before-you-begin
Also, note that phone number sign-in requires a physical device and won't work on an emulator.
UPDATE Take a look at Prasanna Anbu's answer.
After spending the whole Day figuring out what was the issue. I've found the culprit! It was in the App Signing for Google Play that we have opted-in. We need to register the SHA-1 from the App Signing itself. It can be found in the inside Google Play Console under Setup > App Integrity. It will have two types of certificate:
1. Upload certificate : this is the information of the certificate from the keystore that uploaded. This is needed to be the same with the keystore for app signing locally as the Google Play will verify the uploaded app to match with this signed certificate.
2. App Signing certificate : after uploaded the app, Google will replace the upload certificate with this certificate. This is a new certificate that will be used for published app in Play Store.
With those information, I just realize that we hadn't registered the SHA-1 for the App Signing certificate which being used by published app. So, I added the SHA-1 (also the SHA-256, just in case needed) fingerprints in the Firebase > Project Setting for the app (Don't forget to update the latest config file after added the fingerprints).
So After adding your your SHA Fingerprints your Firebase SHA certificate fingerprints will look like this:
Now Save Changes then Go back to your App and test it again it will work now!.
Your SHA1 key is not registered in your firebase console. Simply generate SHA key as shown in pic below, copy the SHA key from Android Studio terminal and add it in Firebase console project settings:
Also make sure you are using a release keystore to generate this key
After this generate your SHA1 fingerprint else your users will face SHA1 error on phone authentication.
Hope it help somebody.
You need to configure the SHA-1 in firebase console.
You can do it very easily using Android Studio tools.
Tools -> Firebase
in Android Studio.Authentication
or RealtimeDatabase
.Connect to Firebase
and do the required.or
Add it manually. Check out this..
对我来说,问题只是我正在使用模拟器输入未保存为测试电话号码的电话(Firebase-> 身份验证-> 登录方法-> 电话-> 并在此处添加测试电话号码
Generate SHA-1 certificate prefer this link SHA-1 fingerprint of keystore certificate
after open your firebase console and add this SHA-1 Key here.
I was also facing the similar issue in react-native build as show in the below picture. I solved the problem by following the below mentioned steps.
According to @adirzoari open your react native project into android studio and then:
For Android studio 2.2 - result will be available under Run console but use highlighted toggle button.
enter image description here How to fix please verify that the correct package name and sha1 are configured in the firebase console:
Make sure add SHA in firebase in your app Klik Settings -> Project Settings -> General -> Add Fingerprint (SHA 1 in your app) -> Save
And then Klik Authentication -> Sign-in method -> Phone -> Phone number testing (optional) -> Save
Add SHA-1 without SHA-1 mentioning in it. Like you have SHA-1 as :
SHA1: 6G:49:58:57:A2:5C:2R:95:7D:32:19:4A:69:05:14:F2:31:0D:72:0A
Add only this to firebase Project settings
6G:49:58:57:A2:5C:2R:95:7D:32:19:4A:69:05:14:F2:31:0D:72:0A
For more info
You can generate SHA keys from gradle command
./gradlew signingReport
Go to your firebase console -> Authentication -> SIGN-IN Method -> Phone . Add the random numbers with verification code to enter image description here "Phone numbers for testing (optional)" field.
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.