I am integrating Google sign-in for Android and I want the id_token back so I can authenticate with my server. I followed all the steps as in https://developers.google.com/identity/sign-in/android/backend-auth
If I request just requestEmail() then I am getting back the profile information but if I add .requestIdToken(getString(R.string.server_client_id)) then result.isSuccess() is false and I am not getting any account information back. Any ideas?
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.requestIdToken(getString(R.string.server_client_id))
.build();
onActivityResult:
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
if (result.isSuccess()) {
GoogleSignInAccount acct = result.getSignInAccount();
String idToken = acct.getIdToken();
mIdTokenTextView.setText("ID Token: " + idToken);
// TODO(user): send token to server and validate server-side
} else {
mIdTokenTextView.setText("ID Token: null");
}
If I try to call any method on "result" then I get a Null pointer error...
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=9001, result=0, data=Intent { (has extras) }} to activity {com.test.LoginActivity}: java.lang.NullPointerException