You are here

public function GoogleAuthManager::requestEndPoint in Social Auth Google 8.2

Same name and namespace in other branches
  1. 3.x src/GoogleAuthManager.php \Drupal\social_auth_google\GoogleAuthManager::requestEndPoint()

File

src/GoogleAuthManager.php, line 83

Class

GoogleAuthManager
Contains all the logic for Google OAuth2 authentication.

Namespace

Drupal\social_auth_google

Code

public function requestEndPoint($method, $path, $domain = NULL, array $options = []) {
  if (!$domain) {
    $domain = 'https://www.googleapis.com';
  }
  $url = $domain . $path;
  $request = $this->client
    ->getAuthenticatedRequest($method, $url, $this
    ->getAccessToken(), $options);
  try {
    return $this->client
      ->getParsedResponse($request);
  } catch (IdentityProviderException $e) {
    $this->loggerFactory
      ->get('social_auth_google')
      ->error('There was an error when requesting ' . $url . '. Exception: ' . $e
      ->getMessage());
  }
  return NULL;
}