You are here

public function GoogleAuthManager::getUserInfo in Social Auth Google 3.x

Same name and namespace in other branches
  1. 8.2 src/GoogleAuthManager.php \Drupal\social_auth_google\GoogleAuthManager::getUserInfo()
  2. 8 src/GoogleAuthManager.php \Drupal\social_auth_google\GoogleAuthManager::getUserInfo()

Gets data about the user.

Return value

\League\OAuth2\Client\Provider\GenericResourceOwner|array|mixed User info returned by provider.

Overrides OAuth2ManagerInterface::getUserInfo

File

src/GoogleAuthManager.php, line 52

Class

GoogleAuthManager
Contains all the logic for Google OAuth2 authentication.

Namespace

Drupal\social_auth_google

Code

public function getUserInfo() {
  $access_token = $this
    ->getAccessToken();
  if (!$this->user && $access_token != NULL) {
    $this->user = $this->client
      ->getResourceOwner($this
      ->getAccessToken());
  }
  else {
    $this->loggerFactory
      ->get('social_auth_google')
      ->error('There was an error fetching the access token for user.');
  }
  return $this->user;
}