Skip to content

Commit 9fb3b91

Browse files
RixzZlucasmichotatymic
authored
Authentik: add refreshToken method (#1081)
Co-authored-by: Lucas Michot <lucas@semalead.com> Co-authored-by: atymic <atymicq@gmail.com>
1 parent 9645b5c commit 9fb3b91

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

Provider.php

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,30 @@ protected function getTokenUrl()
5555
*/
5656
protected function getUserByToken($token)
5757
{
58-
$response = $this->getHttpClient()->get(
59-
$this->getBaseUrl().'/application/o/userinfo/',
60-
[
61-
RequestOptions::HEADERS => [
62-
'Authorization' => 'Bearer '.$token,
63-
],
64-
]
65-
);
58+
$response = $this->getHttpClient()->get($this->getBaseUrl().'/application/o/userinfo/', [
59+
RequestOptions::HEADERS => [
60+
'Authorization' => 'Bearer '.$token,
61+
],
62+
]);
6663

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

67+
/**
68+
* {@inheritdoc}
69+
*/
70+
protected function refreshToken($refreshToken)
71+
{
72+
return $this->getHttpClient()->post($this->getTokenUrl(), [
73+
RequestOptions::FORM_PARAMS => [
74+
'client_id' => $this->clientId,
75+
'client_secret' => $this->clientSecret,
76+
'grant_type' => 'refresh_token',
77+
'refresh_token' => $refreshToken,
78+
],
79+
]);
80+
}
81+
7082
/**
7183
* {@inheritdoc}
7284
*/

0 commit comments

Comments
 (0)