Getting Profile Information

  • Google Sign-In for Android is outdated and users should migrate to Credential Manager for better security and user experience, except for some Wear OS versions where continued use of Google Sign-in is necessary.

  • Basic profile information and email address can be accessed after a user signs in with Google, depending on the configured parameters.

  • It is important not to use a user's email address or user ID for backend communication; instead, send and validate the user's ID token or use the server auth code flow.

  • The GoogleSignIn.getLastSignedInAccount method can be used to retrieve profile information for the currently signed-in user, but note that profile fields can be null depending on requested scopes and profile information.

After you have signed in a user with Google, if you configured Google Sign-In , with the DEFAULT_SIGN_IN parameter or the requestProfile method, you can access the user's basic profile information. If you configured Google Sign-In with the requestEmail method, you can also get their email address.

Before you begin

Retrieve profile information for a signed-in user

Use the GoogleSignIn.getLastSignedInAccount method to request profile information for the currently signed in user.

 GoogleSignInAccount acct = GoogleSignIn.getLastSignedInAccount(getActivity());
if (acct != null) {
  String personName = acct.getDisplayName();
  String personGivenName = acct.getGivenName();
  String personFamilyName = acct.getFamilyName();
  String personEmail = acct.getEmail();
  String personId = acct.getId();
  Uri personPhoto = acct.getPhotoUrl();
} 

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.

Create a Mobile Website
View Site in Mobile | Classic
Share by: