You are here

public function SalesforceAuthTokenStorage::storeAccessToken in Salesforce Suite 5.0.x

Same name and namespace in other branches
  1. 8.4 src/Storage/SalesforceAuthTokenStorage.php \Drupal\salesforce\Storage\SalesforceAuthTokenStorage::storeAccessToken()
  2. 8.3 src/Storage/SalesforceAuthTokenStorage.php \Drupal\salesforce\Storage\SalesforceAuthTokenStorage::storeAccessToken()

File

src/Storage/SalesforceAuthTokenStorage.php, line 80

Class

SalesforceAuthTokenStorage
Salesforce auth token storage.

Namespace

Drupal\salesforce\Storage

Code

public function storeAccessToken($service, TokenInterface $token) {

  // Salesforce API doesn't return a refresh token when refreshing.
  // If $token refresh token is null, retain existing instead of overwriting.
  if (!$token
    ->getRefreshToken()) {
    $oldToken = $this->state
      ->get(static::getTokenStorageId($service));
    if ($oldToken) {
      $token
        ->setRefreshToken($oldToken
        ->getRefreshToken());
    }
  }
  $this->state
    ->set(static::getTokenStorageId($service), $token);
  return $this;
}