"This app is not authorized to use Firebase Authentication" in Emulator

Viewed 58517

I'm getting this error when I try to run my app on emulator.

What I've done:

  1. I'm using Firebase-UI and running Android O
  2. I have the Play Store updated.
  3. I've added all the SHA-1 code to Firebase console and the package name matches.

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)
13 Answers

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.

enter image description here

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

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:

enter image description here

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:

enter image description here

Also make sure you are using a release keystore to generate this key

enter image description here

enter image description here

After this generate your SHA1 fingerprint else your users will face SHA1 error on phone authentication.

Hope it help somebody.

For me the problem was simply that I was working on an emulator entering a phone not saved as a test phone number (Firebase->authentication->sign in method->Phone-> and add a test phone number 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.

enter image description here

According to @adirzoari open your react native project into android studio and then:

  1. Run your project.
  2. Click on Gradle menu.
  3. Expand Gradle Tasks tree.
  4. Double click on android -> signingReport and you'll see the result

For Android studio 2.2 - result will be available under Run console but use highlighted toggle button.

enter image description hereHow to fix please verify that the correct package name and sha1 are configured in the firebase console:

  1. Make sure add SHA in firebase in your app Klik Settings -> Project Settings -> General -> Add Fingerprint (SHA 1 in your app) -> Save

  2. And then Klik Authentication -> Sign-in method -> Phone -> Phone number testing (optional) -> Save

  • Provide the phone number you want to test, for example: +1 650-555-3434
  • Provide the 6-digit verification code for that specific number, for example: 654321 enter image description here
  1. Whoolaaaaa its work for me "Code been sent" in emulator enter image description here

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 toenter image description here "Phone numbers for testing (optional)" field.

Problem Solve --> enter image description hereenable phone provider and sh1 and sh256 from project setting and also add your country code in a phone number while sending phone number for authentication

Related