android - Firebase 和 Google-Auth 以及 Phone-Auth 的 SHA-1 问题

标签 android firebase firebase-authentication

我目前正在制作一个应用程序,您还可以在其中使用 Firebase 通过您的 Google 帐户或手机号码登录。使用 keytool 我已经读取了我的 SHA-1 并将其存储在 Firebase 的项目设置中(我也在 Android-Studio 中通过 Gradle 读取了 SHA-1 值,当然,它是相同的值就像在 Keytool 中一样。)。当我在调试时测试应用程序时,一切正常。一旦我发布 APK(已签名的 APK V1 和 V2)并安装此 APK,就无法通过 Google 或手机号码登录。 错误:

This app is not authorized to use Firebase Authentication. Please verify the correct package name and SHA-1 are configured in the Firebase Console. [App validation failed]

在 Firebase 控制台中,指定了正确的 SHA-1。或者 APK 在发布后是否具有不同的 SHA-1 值?为什么在调试时一切正常,而不是在发布后?

如果有人能帮助我,那就太好了。

最佳答案

为了防止滥用 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 控制台 -> 身份验证 -> 登录方法 -> 电话并检查“用于测试的电话号码(可选)”字段。

enter image description here

确保您要添加的电话号码之前没有记录/注册过。如果该号码已存在于身份验证中,则您无法将其添加为测试帐户。

如果您没有使用模拟器,请按照以下步骤操作:

Tools>Firebase>Authentication>Connect>Sync

这通常在您更新 android studio 时发生。

关于android - Firebase 和 Google-Auth 以及 Phone-Auth 的 SHA-1 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52188121/

相关文章:

android - "Could not find method packageName()"RC1 错误 - flavor 不编译

java - 如何更改 alertDialog 中项目的字体?

firebase - Firebase项目初始化错误:未为此项目设置云资源位置

api - 用于登录到我的 api 的 Firebase token

javascript - 从 web 应用程序中删除经过 firebase 身份验证的用户

android - 使用错误的验证码进行身份验证时出现异常

node.js - 使用上下文在 firebase 云函数中获取用户 displayName

android - 如何在 Firebase 中将电子邮件地址添加为子地址?

android - 当 URL 中有 "?"时,改造 POST 请求转换为 GET 请求

java - 有限状态机 (FSM) 和 Android 的 Java