I want to have Google Plus login in my application. I could connect but unable to get current user's profile information
@Override
public void onConnected() {
String accountName = mPlusClient.getAccountName();
mPlusClient.loadPerson(this, "me");
}
@Override
public void onPersonLoaded(ConnectionResult status, Person person) {
Log.d("onPersonLoaded - ConnectionResult", "" + status);
Log.d("onPersonLoaded - person", "" + person);
if (status.getErrorCode() == ConnectionResult.SUCCESS) {
Log.d(TAG, "Display Name: " + person.getDisplayName());
}
}
I could get the Account Name in onConnected
But onPersonLoaded
gives null
for person
The logs show:
onPersonLoaded - ConnectionResult(29861): ConnectionResult{statusCode=NETWORK_ERROR, resolution=null}
onPersonLoaded - person(29861): null
From the docs here
public static final int NETWORK_ERROR
A network error occurred. Retrying should resolve the problem.
Constant Value: 7 (0x00000007)
But I get the same error no matter how many times I retry. And these are the permission I use:
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
I have no idea how to resolve this and been searching for the past 2 hours. Any help is highly appreciated, thank you.
finally i found the answer . :)
loadPerson()
andloadPeople()
will return you expected data only in exported APK signed with valid key . by valid here i mean it should match with SHAI and other specification of your API key console .one more thing you could missed when following sample code is define scope in PlusClient constructor, like