public function SalesforceCommands::refreshToken in Salesforce Suite 8.4
Same name and namespace in other branches
- 5.0.x src/Commands/SalesforceCommands.php \Drupal\salesforce\Commands\SalesforceCommands::refreshToken()
Refresh the named authentication token, or the default if none specified.
@command salesforce:refresh-token @aliases sfrt
Parameters
string $providerName: The name of the authentication provider.
Return value
string Message indicating success or failure.
Throws
\OAuth\OAuth2\Service\Exception\MissingRefreshTokenException For missing token.
File
- src/
Commands/ SalesforceCommands.php, line 719
Class
- SalesforceCommands
- A Drush commandfile.
Namespace
Drupal\salesforce\CommandsCode
public function refreshToken($providerName = '') {
// If no provider name given, use the default.
if (empty($providerName)) {
$providerName = $this->authMan
->getConfig()
->id();
}
if ($provider = SalesforceAuthConfig::load($providerName)) {
$auth = $provider
->getPlugin();
$token = $auth
->hasAccessToken() ? $auth
->getAccessToken() : new StdOAuth2Token();
$auth
->refreshAccessToken($token);
return "Access token refreshed for {$providerName}";
}
return "Provider {$providerName} not found.";
}