You are here

public function SalesforceAuthProviderPluginBase::refreshIdentity in Salesforce Suite 8.4

Same name and namespace in other branches
  1. 5.0.x src/SalesforceAuthProviderPluginBase.php \Drupal\salesforce\SalesforceAuthProviderPluginBase::refreshIdentity()

Given a token, fetch the SF identity.

Parameters

\OAuth\Common\Token\TokenInterface $token: The token.

Return value

\Drupal\salesforce\Rest\SalesforceIdentityInterface The refreshed identity.

Throws

\OAuth\OAuth2\Service\Exception\MissingRefreshTokenException Comment.

Overrides SalesforceAuthProviderInterface::refreshIdentity

5 calls to SalesforceAuthProviderPluginBase::refreshIdentity()
SalesforceAuthProviderPluginBase::refreshAccessToken in src/SalesforceAuthProviderPluginBase.php
Perform a refresh of the given token.
SalesforceAuthProviderPluginBase::requestAccessToken in src/SalesforceAuthProviderPluginBase.php
SalesforceAuthProviderPluginBase::save in src/SalesforceAuthProviderPluginBase.php
Callback for configuration form after saving config entity.
SalesforceJWTPlugin::refreshAccessToken in modules/salesforce_jwt/src/Plugin/SalesforceAuthProvider/SalesforceJWTPlugin.php
Perform a refresh of the given token.
SalesforceJWTPlugin::requestAccessToken in modules/salesforce_jwt/src/Plugin/SalesforceAuthProvider/SalesforceJWTPlugin.php
Overrides AbstractService::requestAccessToken for jwt-bearer flow.

File

src/SalesforceAuthProviderPluginBase.php, line 221

Class

SalesforceAuthProviderPluginBase
Shared methods for auth providers.

Namespace

Drupal\salesforce

Code

public function refreshIdentity(TokenInterface $token) {
  $headers = [
    'Authorization' => 'OAuth ' . $token
      ->getAccessToken(),
    'Content-type' => 'application/json',
  ];
  $data = $token
    ->getExtraParams();
  $response = $this->httpClient
    ->retrieveResponse(new Uri($data['id']), [], $headers);
  $identity = new SalesforceIdentity($response);
  $this->storage
    ->storeIdentity($this
    ->service(), $identity);
  return $identity;
}