Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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)
like image 634
Razvan Cristian Lung Avatar asked Aug 16 '17 07:08

Razvan Cristian Lung


People also ask

How do I authorize Firebase?

To authenticate a service account and authorize it to access Firebase services, you must generate a private key file in JSON format. To generate a private key file for your service account: In the Firebase console, open Settings > Service Accounts. Click Generate New Private Key, then confirm by clicking Generate Key.

How do I enable Android verification for Firebase project in?

In the Firebase console, open the Authentication section. In the Sign in method tab, enable the Phone provider if you haven't already. Open the Phone numbers for testing accordion menu. Provide the phone number you want to test, for example: +1 650-555-3434.


2 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

like image 153
Prasanna Anbazhagan Avatar answered Sep 24 '22 11:09

Prasanna Anbazhagan


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

like image 24
Trần Thị Diệu My Avatar answered Sep 20 '22 11:09

Trần Thị Diệu My