Getting profile information

  • Support for the Google Sign-In library is deprecated.

  • Use ID tokens to securely communicate the currently signed in user to your backend server, not Google IDs or profile information.

  • The getBasicProfile() method allows retrieval of a user's basic profile information such as ID, name, profile URL, and email address after signing in.

  • Use the account's ID to identify a user, not their email address, as email addresses can change.

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());
}