如何获取Google身份验证的serverID

时间:2017-07-19 16:07:22

标签: android google-signin google-client googlesigninapi googlesigninaccount

所以我有2个项目,我需要合并它们。 在我需要删除的那个中,我有以下密钥,它适用于GoogleSignInOptions: enter image description here 现在,在我的新项目中。我不知道如何创建它。 它说它是一个服务帐户客户端,但是: 创建凭证 - >创建Oauth客户端ID - >只给了我这个选择:

Web应用程序 Android的 Chrome应用 iOS版 PlayStation 4 其他

我试过,现在有一个按钮: 创建凭证 - >服务帐户密钥 - >但这会返回一个不同的对象,但仍然无法正常工作。我试过了,但只能使用App Engine默认服务帐户。

但我很确定在第一次实施时我没有这样做。 然后我做了一些让我下载google-services.json的东西,然后它也给了我服务器客户端ID。我有一段时间没用过这个,所以我迷失了。我做错了吗?

这是我的代码:

String serverID = getString(R.string.server_client_id);
    Log.i("","handleSignInResult serverid: " + serverID);
    gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestEmail()
            .requestIdToken(serverID)
            .requestServerAuthCode(serverID)
            .build();

1 个答案:

答案 0 :(得分:1)

我认为你必须选择“其他”:

enter image description here

enter image description here

enter image description here

enter image description here

相关问题