Getting profile information

  • Google Sign-In library support is deprecated, and migration to FedCM APIs will be mandatory soon, requiring an impact assessment.

  • After user sign-in, you can access basic profile information like Google ID, name, profile URL, and email address.

  • Instead of Google IDs or profile data, utilize ID tokens for secure backend server authentication.

  • Google account email addresses are subject to change, so use the account's ID for user identification on both client and backend.

After you have signed in a user with Google using the default scopes, you can access the user's Google ID, name, profile URL, and email address.

To retrieve profile information for a user, use the getBasicProfile() method. For example:

// auth2 is initialized with gapi.auth2.init() and a user is signed in.

if (auth2.isSignedIn.get()) {
  var profile = auth2.currentUser.get().getBasicProfile();
  console.log('ID: ' + profile.getId());
  console.log('Full Name: ' + profile.getName());
  console.log('Given Name: ' + profile.getGivenName());
  console.log('Family Name: ' + profile.getFamilyName());
  console.log('Image URL: ' + profile.getImageUrl());
  console.log('Email: ' + profile.getEmail());
}