I'm working on an App and this app has a feature, which need profile ID of Google Account. I can get data using Google People API by using code:
GoogleSignInOptions signInOptions = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
// The serverClientId is an OAuth 2.0 web client ID
.requestServerAuthCode(getString(R.string.googleWebClientId))
.requestEmail()
.requestScopes(new Scope(Scopes.PLUS_LOGIN),
new Scope(PeopleScopes.CONTACTS_READONLY),
new Scope(PeopleScopes.USER_EMAILS_READ),
new Scope(PeopleScopes.USERINFO_EMAIL),
new Scope(PeopleScopes.USER_PHONENUMBERS_READ))
.build();
// To connect with Google Play Services and Sign In
mGoogleApiClient = new GoogleApiClient.Builder(this).
enableAutoManage(this, new GoogleApiClient.OnConnectionFailedListener() {
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
Toast.makeText(AddContactUserToLeaderboardActivity.this, "Your account doesnot exists", Toast.LENGTH_LONG).show();
}
}).addApi(Auth.GOOGLE_SIGN_IN_API, signInOptions).
build();
People peopleService = setUp(AddContactUserToLeaderboardActivity.this, params[0]);
ListConnectionsResponse response = peopleService.people().connections()
.list("people/me")
// This line's really important! Here's why:
// http://stackoverflow.com/questions/35604406/retrieving-information-about-a-contact-with-google-people-api-java
.setRequestMaskIncludeField("person.names,person.emailAddresses,person.phoneNumbers")
.execute();
List<Person> connections = response.getConnections();
Log.e(TAG, "response: " + ((GenericJson) response).toString());
But the response has no Profile ID, it just has Contact ID like that:
{"connections":[{"etag":"%EgQBAgkL","names":[{"displayName":"A","givenName":"B","metadata":{"primary":true,"source":{"id":"5744b9050dfsfa281b","type":"CONTACT"}},...
am I missing any field to have Google Profile ID in this line?setRequestMaskIncludeField("person.names,person.emailAddresses,person.phoneNumbers")
or any idea to get Profile ID from People API Google? Help me please.