ZehnVon12
ZehnVon12

Reputation: 4156

Google+ Platform for Android - getCurrentPerson

I use the Google+ Platform for Android with

PlusClient plusClient = 
  new PlusClient.Builder(this, this, this).setScopes(Scopes.PLUS_LOGIN).build();

In the onConnected-Listener I want to read the data of the logged in user

@Override
public void onConnected() {
  super.onConnected();    
  Person person = plusClient.getCurrentPerson();
}

The method call getCurrentPerson returns null. Has anyone managed to read the user-data?

Upvotes: 6

Views: 2141

Answers (3)

Kasun Wanniarachchi
Kasun Wanniarachchi

Reputation: 544

  • You need to create an OAuth 2 client ID and add your Android app's developer (if you are releasing only add release key, otherwise development key will be enough) signing keys to it, as described in the Google+ Getting Started guide.
  • If you upgrade your API Console to New one, Go To "Consent Screen" and add Product Name(this is required)
  • Go to API Console "APIs & auth" -> "APIs" and enable "Google+ API"

it will work like a charm!!!

Upvotes: 1

samskivert
samskivert

Reputation: 3704

You need to create an OAuth 2 client ID and add your Android app's developer (and probably production) signing keys to it, as described in the Google+ Getting Started guide.

I did the same thing but had not known to create the OAuth 2 client ID, and was getting null from that method (of course with no useful feedback in the logs). After creating the ID and adding my app's signing keys, the method returns an actual Person instance.

Even though you don't actually USE the client ID anywhere in your application, the act of adding your signing key in that interface apparently unlocks something on Google's servers and allows things to work.

Upvotes: 7

Silvano
Silvano

Reputation: 1005

Did you go through the setup steps outlined here?

Upvotes: 1

Related Questions