Firebase身份验证:来自此Android客户端应用程序com.xxx的请求被阻止

时间:2018-08-20 06:52:48

标签: android firebase firebase-authentication

我正在Android应用程序中实现Firebase AuthUI的标准教程。但是,在测试时,我尝试从应用程序中使用Google登录进行登录,并得到以下异常:

com.google.firebase.FirebaseException: An internal error has occurred. 
[ Requests from this Android client application com.xxx are blocked. ]

该应用程序显示“ Google SmartLock”标语,就像它在登录我一样,但随后消失了,在日志目录中,我看到了上面的错误。

我验证了Firebase控制台中用于调试和发布的SHA-1证书指纹。我已经在此应用程序中使用了一段时间,所以我知道它们是正确的。

我已经在Firebase身份验证控制台上启用了Google登录和电子邮件登录。我已经尝试了电子邮件/谷歌登录和这两个过程都开始了,但是由于相同的异常而失败了。我还下载并使用了一个新的google-services.json文件-不变。

应用程序名称正确。他们为什么要阻止我?有人有运气联系Firebase支持人员吗?

这是build.gradle的一个片段:

api 'com.android.support:support-v4:27.1.1'
api 'com.android.support:appcompat-v7:27.1.1'
api 'com.android.support.constraint:constraint-layout:1.1.2'
api 'com.google.firebase:firebase-storage:16.0.1'
api 'com.google.firebase:firebase-core:16.0.1'
api 'com.google.android.gms:play-services-maps:15.0.1'
api 'com.google.android.gms:play-services-location:15.0.1'
api 'com.google.android.gms:play-services-ads:15.0.1'
api 'com.google.code.findbugs:jsr305:3.0.2'
api 'com.google.apis:google-api-services-storage:v1-rev68-1.21.0'
implementation 'com.firebaseui:firebase-ui-storage:0.6.0'
implementation 'com.firebaseui:firebase-ui-auth:4.0.0'
testImplementation 'junit:junit:4.12'

Logcat:

/com.x.x W/BiChannelGoogleApi: [FirebaseAuth: ] getGoogleApiForMethod() returned Gms: com.google.firebase.auth.api.internal.zzal@13ca6fd
/com.x.x D/FA: Logging event (FE): user_engagement(_e), Bundle[{firebase_event_origin(_o)=auto, engagement_time_msec(_et)=12629, firebase_screen_class(_sc)=PhotoActivity, firebase_screen_id(_si)=-1316627329056180637}]
/com.x.x D/FA: Logging event (FE): screen_view(_vs), Bundle[{firebase_event_origin(_o)=auto, firebase_previous_class(_pc)=PhotoActivity, firebase_previous_id(_pi)=-1316627329056180637, firebase_screen_class(_sc)=KickoffActivity, firebase_screen_id(_si)=-1316627329056180636}]
/com.x.x D/FA: Connected to remote service
/com.x.x D/FA: Logging event (FE): user_engagement(_e), Bundle[{firebase_event_origin(_o)=auto, engagement_time_msec(_et)=1312, firebase_screen_class(_sc)=KickoffActivity, firebase_screen_id(_si)=-1316627329056180636}]
/com.x.x D/FA: Logging event (FE): screen_view(_vs), Bundle[{firebase_event_origin(_o)=auto, firebase_previous_class(_pc)=KickoffActivity, firebase_previous_id(_pi)=-1316627329056180636, firebase_screen_class(_sc)=SingleSignInActivity, firebase_screen_id(_si)=-1316627329056180635}]
/com.x.x D/FA: Logging event (FE): screen_view(_vs), Bundle[{firebase_event_origin(_o)=auto, firebase_previous_class(_pc)=SingleSignInActivity, firebase_previous_id(_pi)=-1316627329056180635, firebase_screen_class(_sc)=SignInHubActivity, firebase_screen_id(_si)=-1316627329056180634}]
/com.x.x W/BiChannelGoogleApi: [FirebaseAuth: ] getGoogleApiForMethod() returned Gms: com.google.firebase.auth.api.internal.zzal@13ca6fd
/com.x.x D/FA: Logging event (FE): screen_view(_vs), Bundle[{firebase_event_origin(_o)=auto, firebase_previous_class(_pc)=SignInHubActivity, firebase_previous_id(_pi)=-1316627329056180634, firebase_screen_class(_sc)=SingleSignInActivity, firebase_screen_id(_si)=-1316627329056180635}]
E/Volley: [23564] BasicNetwork.performRequest: Unexpected response code 403 for https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyAssertion?alt=proto&key=[key]
E/Volley: [23564] BasicNetwork.performRequest: Unexpected response code 403 for https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyAssertion?alt=proto&key=[key]
I/AuthChimeraService: Error description received from server: Requests from this Android client application com.x.x are blocked.

/com.x.x E/AuthUI: A sign-in error occurred.
com.google.firebase.FirebaseException: An internal error has occurred. [ Requests from this Android client application com.x.x are blocked. ]

10 个答案:

答案 0 :(得分:3)

我使用的Google Cloud API密钥仅限于具有我的包名称的android,但仅提供了生产SHA-1证书指纹,而没有给出调试密钥。我添加了调试密钥的SHA-1证书以及软件包名称,以便生产证书和调试证书都出现在密钥的“应用程序限制”中,并且可以正常工作。显然受到Firebase的“阻止”意味着您的API密钥可能受到不当限制。

答案 1 :(得分:3)

对于可能遇到此问题的其他任何人,您可能正在 Play 控制台上使用内部应用共享,并启用了 Google 签名。如果是这样,您可能忘记将他们的调试 SHA-1 密钥添加到您的 Firebase 控制台。

很难调试,也很难找到答案,所以我希望我已经添加了所有正确的关键字来帮助下一个人。

答案 2 :(得分:1)

当我为Project更改平台时,我也遇到了同样的问题。即使我将SHA-1密钥添加到Firebase控制台也无法正常工作。使用我的项目名称签入Google Cloud Platform(console.cloud.google.com)之后。我显示自动生成的API密钥不包含新的SHA-1密钥。所以我通过添加项目的程序包名称和SHA键来手动更新它,并且可以使用。

答案 3 :(得分:1)

我遇到了这个问题,向左右寻找解决方案。至少就我而言,事实证明,您实际上需要转到Google Cloud Platform中的“凭据”屏幕,您将在其中找到以下内容:

限制对Android应用的使用 添加您的程序包名称和SHA-1签名证书指纹,以限制对Android应用程序的使用

您可以在ADD NEW ITEM那里,这意味着您的应用程序包及其SHA-1签名。然后,您将不再有此问题(假设其余配置已完成)。我的应用程序的密钥仅限于Android应用程序,这一步是必要的步骤。

答案 4 :(得分:1)

我们的应用在生产环境中正常运行了好几个月,但在将 Firebase SDK 升级到最新版本后,我们最近(2021 年 7 月)开始遇到同样的错误。

我们在 Firebase Phone Auth Docs 中找到了解决方案:

<块引用>

如果用户的设备安装了 Google Play 服务,并且 Firebase 身份验证可以使用 Android SafetyNet 验证该设备是否合法,则可以继续进行电话号码登录。

正如文档所建议的,解决方案是转到 Android Device Verification API 并在 Google Cloud 中为我们的项目启用 API。

之前(不工作) Disabled Android Device Verification

之后(工作) Enabled Android Device Verification

进行更改后,我们所有的电话号码登录/注册功能几乎立即就可以重新开始工作了。

答案 5 :(得分:0)

我今天遇到了同样的问题,幸运的是解决了这个问题。我仍然不知道为什么会这样,但是这是我已解决的步骤:

  1. 在Firebase控制台设置中删除已添加的SHA-1签名证书指纹。
  2. 转到android studio并使用Gradle文件同步项目。
  3. 再次将SHA-1签名证书指纹添加到Firebase控制台设置。

这是将SHA-1签名证书指纹添加到Firebase的方法:CLICK HERE

答案 6 :(得分:0)

我注意到出于某种原因,由于我的Google Credentials API密钥限制,我的SHA-1指纹未包括在内。

要找到您的API密钥,请访问console.cloud.google.com/apis/credentials?project=。 或转到console.cloud.google.com->单击左上角的汉堡包图标-> API和服务->凭据

选择您正在使用的API密钥。 -在“应用限制”下,选择“ Android应用”(例如,如果您正在构建Android应用) -在“限制对Android应用的使用”下,单击“添加项目” -输入包裹名称和SHA-1指纹

要了解如何查找SHA-1指纹,请LINK

signingReport任务可能位于Gradle(在右侧垂直带)应用程序下->任务-> android

答案 7 :(得分:0)

就我而言:

如果您使用的是Google Play应用签名,只需登录Firebase进入“项目设置”->“集成”,然后按一下按钮即可将Google Play与Firebase链接,SHA-1将自动添加。下载并更改新的google-services.json

如果仍然遇到问题,请转到Google Cloud API,然后单击左上角的汉堡包图标-> API和服务->凭据。选择您正在使用的API密钥。在限制下,选择“无”。

答案 8 :(得分:0)

如果您将应用发布到Google Play商店,然后显示此错误:

[ Requests from this Android client application com.x.x are blocked. ]

这是一种非常容易解决问题的解决方案。

  1. 打开Goog​​le Play控制台-> https://play.google.com/apps/publish
  2. 转到您的特定应用程序,哪个应用程序显示错误。
  3. 然后去Setup -> App signin
  4. 最后您得到了SHA-1 certificate fingerprint

要找到您的SHA-1证书指纹,请转到console.cloud.google.com/apis/credentials?project。或转到console.cloud.google.com->单击top left -> APIs and Services -> Credentials上的汉堡包图标。然后更改所有SHA-1 certificate fingerprint

答案 9 :(得分:0)

就我而言,我按照以下步骤遇到了这个问题:

  • 首先,我删除了 SHA-1 和 SHA - 256 个密钥。
  • 构建我的 Gradle。
  • 添加了 FirebaseApp.initializeApp(this);在我的 Baseapp 中。
  • 再次添加我的 SHA 密钥并运行我的应用程序。
  • 问题已解决。