public function Storage::setRefreshToken in OAuth2 Server 7
File
- lib/
Drupal/ oauth2_server/ Storage.php, line 403
Class
- Storage
- Provides Drupal storage (through the underlying Entity API) for the library.
Namespace
Drupal\oauth2_serverCode
public function setRefreshToken($refresh_token, $client_key, $uid, $expires, $scope = null) {
$client = oauth2_server_client_load($client_key);
if (!$client) {
throw new \InvalidArgumentException("The supplied client couldn't be loaded.");
}
// If no token was found, start with a new entity.
$token = oauth2_server_token_load($refresh_token);
if (!$token) {
$user = user_load($uid);
if (!$user) {
throw new \InvalidArgumentException("The supplied user couldn't be loaded.");
}
$token = entity_create('oauth2_server_token', array(
'type' => 'refresh',
));
$token->client_id = $client->client_id;
$token->uid = $uid;
$token->token = $refresh_token;
}
$token->expires = $expires;
$this
->setScopeData($token, $client->server, $scope);
$status = $token
->save();
return $status;
}