使用 Google Fit 的 android 应用中的 OAuth 同意屏幕空白

OAuth consent screen blank in android app with Google Fit

我正在尝试在我的应用程序中使用 Google Fit API,但在提示用户选择 Google 帐户后,应该会显示 OAuth 同意屏幕我只得到一个带有不确定加载指示器的空白弹出窗口,除非我取消它,否则此弹出窗口将保持原样。

Image of the popup

不显示任何错误消息,只有当我取消登录流程时,我才会收到取消它的错误消息。

我试过个人项目以及Google's sample proyect, where other users are also experiencing the same issue

正如我在该问题上所描述的那样,我已经在模拟器(Huawei Pro 20 Lite)和另一台设备上使用四个不同的帐户测试了这两个应用程序,但得到了相同的结果。

在 Google 云控制台中也有正确的配置,使用正确的 applicationId 和 SHA1 签名密钥,我尝试了两个不同的云项目,其中一个是全新的。

启动登录流程的功能是这个,可以找到示例应用程序的完整代码here

GoogleSignIn.requestPermissions(
    this,
    requestCode.ordinal,
    getGoogleAccount(), fitnessOptions)

感谢您的帮助。

按照 http://developers.google.com/fit/android/get-started 处的说明注册 Android 客户端。

确保为您的 Cloud 项目启用了 Fit API。

检查您的 Cloud 项目凭据:

  • 确保您的凭据包名称与示例匹配。
  • 确保包名称与 app/build.gradle 文件中的 applicationId 匹配。
  • 确保签名证书指纹输入正确。

另外从 OAuthConsentScreen 添加测试用户并将用户类型设置为外部

我找到了一个解决方案,它很奇怪,但无论如何它对我有用:

  • 删除您的 Cloud 项目
  • 不要按照 http://developers.google.com/fit/android/get-started 中的以下说明使用 firebase 创建一个新项目。
  • 在 firebase 项目设置中添加一个 android 应用程序
  • 同时添加 SHA1 和 SHA256。
  • 将google-services.json下载到项目文件夹中的android/app。
  • 确保在常规项目设置中设置我的“支持电子邮件”。

如果这没有帮助,请同时检查 Flutter and google_sign_in plugin: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null)

大家对 GoogleSignIn 也有类似的问题