Skip to content

Commit

Permalink
Authentik: add refreshToken method (#1081)
Browse files Browse the repository at this point in the history
Co-authored-by: Lucas Michot <[email protected]>
Co-authored-by: atymic <[email protected]>
  • Loading branch information
3 people authored Sep 8, 2023
1 parent e02959c commit 36c0fdb
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions src/Authentik/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,30 @@ protected function getTokenUrl()
*/
protected function getUserByToken($token)
{
$response = $this->getHttpClient()->get(
$this->getBaseUrl().'/application/o/userinfo/',
[
RequestOptions::HEADERS => [
'Authorization' => 'Bearer '.$token,
],
]
);
$response = $this->getHttpClient()->get($this->getBaseUrl().'/application/o/userinfo/', [
RequestOptions::HEADERS => [
'Authorization' => 'Bearer '.$token,
],
]);

return json_decode((string) $response->getBody(), true);
}

/**
* {@inheritdoc}
*/
protected function refreshToken($refreshToken)
{
return $this->getHttpClient()->post($this->getTokenUrl(), [
RequestOptions::FORM_PARAMS => [
'client_id' => $this->clientId,
'client_secret' => $this->clientSecret,
'grant_type' => 'refresh_token',
'refresh_token' => $refreshToken,
],
]);
}

/**
* {@inheritdoc}
*/
Expand Down

0 comments on commit 36c0fdb

Please sign in to comment.