Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GoogleSignIn.getLastSignedInAccount() returns account with null fields

I'm implementing Google Sign-in in my project, but this problem is difficult. When I'm not signed, GoogleSignIn.getLastSignedInAccount(activity) returns null, which is what it should do, according to Google's documentation. When I restart the app, it returns a GoogleSignInAccount, but with all fields null.

Google says:

For additional profile data that might be available, see GoogleSignInAccount. Note that any of the profile fields can be null, depending on which scopes you requested and what information the user's profile includes.

So I thought the problem would be the lack of requested information, but I properly previously defined them with:

GoogleSignIn.getClient(activity, GoogleSignInOptions.Builder()
    .requestId()
    .requestProfile()
    .requestEmail()
    .build()
);

Besides, all informations comes in a perfect GoogleSignInAccount after signing up using the same client request above.

like image 271
Adobe Alura Avatar asked Jan 17 '18 03:01

Adobe Alura


1 Answers

In my game, when GoogleSignIn.getLastSignedInAccount(activity) return null, I call startSigninIntent:

private void startSignInIntent() {
  GoogleSignInClient signInClient = GoogleSignIn.getClient(this,
      GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN);
  Intent intent = signInClient.getSignInIntent();
  startActivityForResult(intent, RC_SIGN_IN);
}
like image 194
Minato Avatar answered Nov 08 '22 08:11

Minato