Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authentik: add refreshToken method #1081

Merged
merged 3 commits into from
Sep 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we type this to string?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess so. I didn't type it since the rest of the provider isn't.

Should I add the type then?

{
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
Loading