public function AccessTokenRefresh::refresh in Simple OAuth (OAuth2) & OpenID Connect 8
Controller to return the access token when a refresh token is provided.
@todo: Get some flood protection for this, since the request is uncacheable because of the expire counter. Also, there has to be some other better way to render JSON. Investigate that too!
1 string reference to 'AccessTokenRefresh::refresh'
File
- src/
Controller/ AccessTokenRefresh.php, line 55
Class
Namespace
Drupal\simple_oauth\ControllerCode
public function refresh() {
$account = $this
->currentUser()
->getAccount();
// If the account is not a token account, then bail.
if (!$account instanceof TokenAuthUserInterface) {
// TODO: Set the error headers appropriately.
return NULL;
}
$refresh_token = $account
->getToken();
if (!$refresh_token) {
// TODO: Set the error headers appropriately.
return NULL;
}
// Find / generate the access token for this refresh token.
$access_token = $refresh_token
->refresh();
if (!$access_token) {
// TODO: Set the error headers appropriately.
return NULL;
}
$this->response
->setData($this
->normalize($access_token));
return $this->response;
}