Đang lấy thông tin hồ sơ

Sau khi đăng nhập người dùng thông qua Google bằng các phạm vi mặc định, bạn có thể truy cập vào mã Google, tên, URL hồ sơ và địa chỉ email của người dùng đó.

Để truy xuất thông tin hồ sơ của người dùng, hãy sử dụng phương thức getBasicProfile(). Ví dụ:

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