0

Android 应用程序中的 Google+ API 签名问题 - 在 google 登录成功结果后,我使用 google+ api 在以下方法中获取“NULL”值登录

代码

GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
        .requestEmail()
        .requestProfile()


        .requestScopes(new Scope(Scopes.PROFILE))
        .build();

mGoogleApiClient = new GoogleApiClient.Builder(this)
        .enableAutoManage(this, this)
        .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
        .addConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() {
            @Override
            public void onConnected(@Nullable Bundle bundle) {
                googleSignOut();
            }

            @Override
            public void onConnectionSuspended(int i) {

            }
        })
        .build();

结果:

      if (result.isSuccess()) {
    String personName = acct.getDisplayName();
String name=acct.getGivenName();
    }

在上述结果代码中都返回空值。

如何获取姓名、名字或姓氏。

4

1 回答 1

0

从谷歌开发控制台创建网络令牌并在你的安卓应用程序中使用它。googleblog上有关于此的精彩指南。如果你按照它,那么我相信,你的问题将得到解决。前段时间也发生在我身上,然后我跟着他们,我的问题得到了解决。

在此处输入图像描述

GoogleSignInOptions gso =
new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
    .requestIdToken(serverClientId) // here you will pass the client server id that you created
    .requestEmail()
    .build();

我希望这会以某种方式帮助你。

于 2017-05-01T14:47:55.030 回答