I am connecting Google People API to the Android app following this manual: http://blog.iamsuleiman.com/people-api-android-tutorial-1/
I am using the following code to sign in:
GoogleSignInOptions signInOptions = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.requestScopes(new Scope(Scopes.PLUS_LOGIN),
new Scope(PeopleScopes.CONTACTS_READONLY),
new Scope(PeopleScopes.USER_PHONENUMBERS_READ))
.requestServerAuthCode(getString(R.string.google_oauth_client_id), false)
.build();
mGoogleApiClient = new GoogleApiClient.Builder(getContext())
.enableAutoManage(getActivity(), this)
.addApi(Auth.GOOGLE_SIGN_IN_API, signInOptions)
.build();
Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent( mGoogleApiClient );
startActivityForResult( signInIntent, GOOGLE_PLUS_RC_SIGN_IN );
The onActivityResult code is:
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
...
}
I keep getting DEVELOPER_ERROR in result.
The app is signed by the code which SHA1 fingerprint I setup in the developer console.
The OAUTH client ID is taken from the "Web client" JSON configuration of my app.
All APIs are enabled in the Google developer console
If I remove the method .requestServerAuthCode():
GoogleSignInOptions signInOptions = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.requestScopes(new Scope(Scopes.PLUS_LOGIN),
new Scope(PeopleScopes.CONTACTS_READONLY),
new Scope(PeopleScopes.USER_PHONENUMBERS_READ))
.build();
The result of
Auth.GoogleSignInApi.getSignInResultFromIntent(data);
is successful: the app is asking for the permission.
What I am doing wrong?
Why requestServerAuthCode causes DEVELOPER_ERROR, despite there is an example of using this method in Google's manual:
Is there any sample how to use People API in Android app?