I am trying to get the user's information, including gender and age, from its Google Plus account. Since these fields may be private, I thought that requesting them explicitly would solve the problem. However, although the sign in dialog states explicitly that the app requests to View your complete date of birth
, I fail to get the birthday.
These are my scopes (tried many variations):
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
//.requestScopes(new Scope(Scopes.PROFILE))
//.requestScopes(new Scope(Scopes.PLUS_LOGIN))
.requestScopes(new Scope("https://www.googleapis.com/auth/user.birthday.read"),
new Scope("https://www.googleapis.com/auth/userinfo.profile"))
//.requestProfile()
.requestEmail()
.build();
mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this, this)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.addApi(Plus.API)
.addScope(new Scope(Scopes.PROFILE))
.build();
When using the deprecated getCurrentPerson
in onActivityResult
, I get null value:
if (requestCode == RC_SIGN_IN) {
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
if (mGoogleApiClient.hasConnectedApi(Plus.API)) {
Person person = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);
if (person != null) {
Log.i(TAG, person.getDisplayName()); //returns full name successfully
Log.i(TAG, person.getGender()); //0
Log.i(TAG, person.getBirthday()); //null
}
}
}
I also tried to get it from the account (GoogleSignInAccount account = result.getSignInAccount()
) but as far as I've searched, this variable doesn't own the requested data at all.
Am I missing something? Or maybe it's impossible to get private data although explicit request?
Thanks.
BTW, I haven't tried yet a scenario with a private gender.