Support scope param in client credentials grant.

This commit is contained in:
flash 2024-09-03 18:12:28 +00:00
parent 33dd519029
commit a74b1a2fab

View file

@ -45,6 +45,12 @@ final class ClientCredsRoutes extends RouteHandler {
<input type=password name=client_secret required>
</label>
</div>
<div>
<label>
<span>Scope:</span>
<input type=text name=scope>
</label>
</div>
<div>
<span>Authentication:</span>
<label>
@ -95,6 +101,7 @@ HTML;
$clientId = (string)$content->getParam('client_id');
$clientSecret = (string)$content->getParam('client_secret');
$auth = (string)$content->getParam('auth');
$scope = (string)$content->getParam('scope');
$headers = [];
$body = ['grant_type' => 'client_credentials'];
@ -105,6 +112,9 @@ HTML;
} else
$headers[] = sprintf('Authorization: Basic %s', base64_encode(sprintf('%s:%s', $clientId, $clientSecret)));
if($scope !== '')
$body['scope'] = $scope;
$body = Tools::shuffleArray($body);
$response = Tools::fetch($tokenUri, headers: $headers, body: $body);