谷歌Android加getCurrentPerson返回nullAndroid、谷歌、null、getCurrentPerson

2023-09-08 09:51:55 作者:想ㄣ那些曾经へ

当我打电话 plusClient.getCurrentPerson()我收到NULL。

When I'm calling plusClient.getCurrentPerson() I am getting NULL.

方法 onConnected(包...)称为成功登录后:

Method onConnected(Bundle...) called after a successful login:

@Override
public void onConnected(Bundle bundle)
{
   if (plusClient.getCurrentPerson() == null)
   {
      Log.e("DD", "Person is null !");
   }
}

我从月食( - > preferences-> Android->生成窗口)直接加入SHA1。我不知道我做错了!

I have added SHA1 directly from eclipse (Window->Preferences->Android->Build). I don't know what I am doing wrong!

在Eclipse ADT SHA1指纹

SHA1 fingerprint from Eclipse ADT

安装的应用程序的客户端ID

Client ID for installed applications

简单API访问

Simple API access

推荐答案

我刚刚发现,你需要通过多个范围,当你正在构建的PlusClient对象:

I just found out that you need to pass multiple scopes when you're building the PlusClient object:

PlusClient plusClient = new PlusClient.Builder(this, this, this).setScopes(Scopes.PLUS_LOGIN, Scopes.PLUS_PROFILE ,"https://www.googleapis.com/auth/userinfo.email").build();