android - 为什么我会收到 com.google.android.gms.common.api.ApiException : 10:?

标签 android firebase-authentication

private void handleSignInResult(Task<GoogleSignInAccount> completedTask) {
    try {
        GoogleSignInAccount account = completedTask.getResult(ApiException.class); //exception is here

        // Signed in successfully, show authenticated UI.
        System.out.println("google token ---> " + account.getIdToken());
    } catch (ApiException e) {
        // The ApiException status code indicates the detailed failure reason.
        // Please refer to the GoogleSignInStatusCodes class reference for more information about this error.
        e.printStackTrace();
    }
}

最佳答案

引用 documentation :

Certain Google Play services (such as Google Sign-in and App Invites) require you to provide the SHA-1 of your signing certificate so we can create an OAuth2 client and API key for your app.

如果您使用的是 Firebase 并尝试使用 debug app:

1.首先,获取您的 SHA-1 调试 key :

  1. 点击Gradle(从右侧面板,你会看到Gradle Bar)
  2. 点击任务
  3. 点击Android
  4. 双击signingReport(你会得到SHA-1MD5)

<强>2。将您的 key 添加到您的 Firebase 项目:

  1. 进入项目设置 -> SHA证书指纹 -> 添加调试应用的SHA-1键。

  2. 然后您可以在您的 Android 项目中更新您的 google-services.json 文件。

它对我有用。

关于android - 为什么我会收到 com.google.android.gms.common.api.ApiException : 10:?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47437678/

相关文章:

android - 如何以编程方式在 Android 设备上处理 "install"文件

javascript - Firebase Google 登录(网络)流程

node.js - Firebase Admin SDK 用于从服务器登录用户

android - 如何让用户在 Firebase 中退出?

javascript - 如何修复 "Uncaught ReferenceError: firebase is not defined"错误?

javascript - 创建用户时将数据写入 Firestore 不起作用

android - 插入时数据类型不匹配(代码 20)

android - Calabash - 我的设备不会旋转

android - GCM 的注册 ID 重复

android - 自定义选项卡指示器(像指示器一样向下箭头)