You are here

public function FacebookAuthManager::getUserInfo in Social Auth Facebook 3.x

Same name and namespace in other branches
  1. 8.2 src/FacebookAuthManager.php \Drupal\social_auth_facebook\FacebookAuthManager::getUserInfo()
  2. 8 src/FacebookAuthManager.php \Drupal\social_auth_facebook\FacebookAuthManager::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/FacebookAuthManager.php, line 61

Class

FacebookAuthManager
Contains all the logic for Facebook OAuth2 authentication.

Namespace

Drupal\social_auth_facebook

Code

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