You are here

public function GoogleApiClient::getAccessTokenWithRefreshToken in Google API PHP Client 8

Wrapper for Google_Client::fetchAccessTokenWithRefreshToken.

Return value

array|bool token array or false.

1 call to GoogleApiClient::getAccessTokenWithRefreshToken()
GoogleApiClient::setAccessToken in src/Service/GoogleApiClient.php
Wrapper for Google_Client::setAccessToken.

File

src/Service/GoogleApiClient.php, line 130

Class

GoogleApiClient
Class Google API Client Service.

Namespace

Drupal\google_api_client\Service

Code

public function getAccessTokenWithRefreshToken() {

  // Get the refresh token from Cache. This is only send the first time.
  $refreshTokenCache = $this
    ->getTokenCache('google_access_token');
  if (!empty($refreshTokenCache)) {
    $token = $this->googleClient
      ->fetchAccessTokenWithRefreshToken($refreshTokenCache);
    if (isset($token['access_token'])) {
      $this
        ->setTokenCache('google_access_token', $token);
      return $token;
    }
  }
  return FALSE;
}