[英]"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:我做了什么:
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.为了防止滥用,firebase 电话身份验证在模拟器中不起作用。
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.
但是,如果您希望将其用于测试目的,那么您应该在 firebase 控制台中添加一些可在模拟器中使用的测试电话号码。
Go to your firebase console -> Authentication -> SIGN-IN Method -> Phone and check the "Phone numbers for testing (optional)" field.转到您的 Firebase 控制台 -> 身份验证 -> 登录方法 -> 电话并检查“测试电话号码(可选)”字段。
sha1 generation in android studio: android studio 中的 sha1 代:
Select Gradle in android studio from right panel从右侧面板中选择 android studio 中的 Gradle
Select Your App选择您的应用
In tasks -> android-> signingReport在任务-> android->signingReport
Double click signingReport.双击签名报告。
You will find the sha1 fingerprint in the "Gradle Console"你会在“Gradle Console”中找到sha1指纹
add this sha1 fingerprint in firebase console在 firebase 控制台中添加这个 sha1 指纹
OK, so it is a documented error.好的,所以这是一个记录错误。 https://github.com/firebase/FirebaseUI-Android/issues/790 and https://github.com/firebase/FirebaseUI-Android/issues/868
https://github.com/firebase/FirebaseUI-Android/issues/790和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文档在这里: 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.更新看看Prasanna Anbu的回答。
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.
我们是在 Google Play 应用签名中选择加入的。 We need to register the SHA-1 from the App Signing itself.
我们需要从 App Signing 本身注册 SHA-1。 It can be found in the inside Google Play Console under Setup > App Integrity.
它可以在设置 > 应用程序完整性下的 Google Play 控制台内部找到。 It will have two types of certificate:
它将有两种类型的证书:
1. Upload certificate : this is the information of the certificate from the keystore that uploaded. 1.上传证书:这是上传的密钥库中的证书信息。 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.
这需要与本地应用程序签名的密钥库相同,因为 Google Play 将验证上传的应用程序以与此签名证书匹配。
2. App Signing certificate : after uploaded the app, Google will replace the upload certificate with this certificate. 2.应用签名证书:上传应用后,谷歌将用此证书替换上传证书。 This is a new certificate that will be used for published app in Play Store.
这是一个新证书,将用于在 Play 商店中发布的应用程序。
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.有了这些信息,我才意识到我们没有为已发布的应用程序使用的应用程序签名证书注册 SHA-1。 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).
因此,我在应用程序的 Firebase > 项目设置中添加了 SHA-1(还有 SHA-256,以防万一)指纹(添加指纹后不要忘记更新最新的配置文件)。
So After adding your your SHA Fingerprints your Firebase SHA certificate fingerprints will look like this:因此,添加您的 SHA 指纹后,您的 Firebase SHA 证书指纹将如下所示:
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.您的 SHA1 密钥未在 Firebase 控制台中注册。 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:
只需生成如下图所示的 SHA 密钥,从 Android Studio 终端复制 SHA 密钥并将其添加到 Firebase 控制台项目设置中:
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.在此之后生成您的 SHA1 指纹,否则您的用户将在电话身份验证时面临 SHA1 错误。
Hope it help somebody.希望它可以帮助某人。
You need to configure the SHA-1 in firebase console.您需要在 firebase 控制台中配置SHA-1 。
You can do it very easily using Android Studio tools.您可以使用 Android Studio 工具轻松完成。
Tools -> Firebase
in Android Studio.Tools -> Firebase
。Authentication
or RealtimeDatabase
.Authentication
或RealtimeDatabase
。Connect to Firebase
and do the required.Connect to Firebase
并执行所需操作。 or或者
Add it manually.手动添加。 Check out this..
看看这个..
How to add SHA-1 to android application 如何将 SHA-1 添加到 Android 应用程序
对我来说,问题只是我正在使用模拟器输入未保存为测试电话号码的电话(Firebase-> 身份验证-> 登录方法-> 电话-> 并在此处添加测试电话号码
Generate SHA-1 certificate prefer this link SHA-1 fingerprint of keystore certificate生成 SHA-1 证书首选此链接密钥库证书的 SHA-1 指纹
after open your firebase console and add this SHA-1 Key here.打开 Firebase 控制台并在此处添加此 SHA-1 密钥后。
I was also facing the similar issue in react-native build as show in the below picture.我在 react-native 构建中也遇到了类似的问题,如下图所示。 I solved the problem by following the below mentioned steps.
我按照下面提到的步骤解决了这个问题。
According to @adirzoari open your react native project into android studio and then:根据@adirzoari,将您的本机项目打开到 android studio 中,然后:
For Android studio 2.2 - result will be available under Run console but use highlighted toggle button.对于 Android studio 2.2 - 结果将在运行控制台下可用,但使用突出显示的切换按钮。
enter image description here How to fix please verify that the correct package name and sha1 are configured in the firebase console:在此处输入图像描述如何修复请验证是否在 firebase 控制台中配置了正确的包名称和 sha1:
Make sure add SHA in firebase in your app Klik Settings -> Project Settings -> General -> Add Fingerprint (SHA 1 in your app) -> Save确保在您的应用中的 firebase 中添加 SHA 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.添加 SHA-1 而不在其中提及 SHA-1。 Like you have SHA-1 as :
就像你有 SHA-1 一样:
SHA1: 6G:49:58:57:A2:5C:2R:95:7D:32:19:4A:69:05:14:F2:31:0D:72:0A 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仅将此添加到 firebase 项目设置
6G:49:58:57:A2:5C:2R:95:7D:32:19:4A:69:05:14:F2:31:0D:72:0A 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您可以从 gradle 命令生成 SHA 密钥
./gradlew signingReport ./gradlew 签名报告
Go to your firebase console -> Authentication -> SIGN-IN Method -> Phone .转到您的 firebase 控制台 -> Authentication -> SIGN-IN Method -> Phone 。 Add the random numbers with verification code to enter image description here "Phone numbers for testing (optional)" field.
添加带有验证码的随机数字以在此处“测试电话号码(可选)”字段中输入图像描述。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.