You are here

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

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

Request and end point.

Parameters

string $method: The HTTP method for the request.

string $path: The path to request.

string|null $domain: The domain to request.

array $options: Request options.

Return value

array|mixed Data returned by provider.

Overrides OAuth2ManagerInterface::requestEndPoint

File

src/GoogleAuthManager.php, line 87

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