public function RestClient::refreshToken in Salesforce Suite 8.3
Refresh access token based on the refresh token.
Throws
\Exception
Overrides RestClientInterface::refreshToken
Deprecated
in 8.x-4.0, use \Drupal\salesforce\SalesforceAuthProviderInterface::refreshAccessToken instead.
1 call to RestClient::refreshToken()
- RestClient::apiCall in src/
Rest/ RestClient.php - Make a call to the Salesforce REST API.
File
- src/
Rest/ RestClient.php, line 488
Class
- RestClient
- Objects, properties, and methods to communicate with the Salesforce REST API.
Namespace
Drupal\salesforce\RestCode
public function refreshToken() {
$refresh_token = $this
->getRefreshToken();
if (empty($refresh_token)) {
throw new \Exception(t('There is no refresh token.'));
}
$data = UrlHelper::buildQuery([
'grant_type' => 'refresh_token',
'refresh_token' => urldecode($refresh_token),
'client_id' => $this
->getConsumerKey(),
'client_secret' => $this
->getConsumerSecret(),
]);
$url = $this
->getAuthTokenUrl();
$headers = [
// This is an undocumented requirement on Salesforce's end.
'Content-Type' => 'application/x-www-form-urlencoded',
];
$response = $this
->httpRequest($url, $data, $headers, 'POST');
$this
->handleAuthResponse($response);
return $this;
}