Support scope param in client credentials grant.
This commit is contained in:
parent
33dd519029
commit
a74b1a2fab
1 changed files with 10 additions and 0 deletions
|
@ -45,6 +45,12 @@ final class ClientCredsRoutes extends RouteHandler {
|
||||||
<input type=password name=client_secret required>
|
<input type=password name=client_secret required>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<label>
|
||||||
|
<span>Scope:</span>
|
||||||
|
<input type=text name=scope>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<span>Authentication:</span>
|
<span>Authentication:</span>
|
||||||
<label>
|
<label>
|
||||||
|
@ -95,6 +101,7 @@ HTML;
|
||||||
$clientId = (string)$content->getParam('client_id');
|
$clientId = (string)$content->getParam('client_id');
|
||||||
$clientSecret = (string)$content->getParam('client_secret');
|
$clientSecret = (string)$content->getParam('client_secret');
|
||||||
$auth = (string)$content->getParam('auth');
|
$auth = (string)$content->getParam('auth');
|
||||||
|
$scope = (string)$content->getParam('scope');
|
||||||
|
|
||||||
$headers = [];
|
$headers = [];
|
||||||
$body = ['grant_type' => 'client_credentials'];
|
$body = ['grant_type' => 'client_credentials'];
|
||||||
|
@ -105,6 +112,9 @@ HTML;
|
||||||
} else
|
} else
|
||||||
$headers[] = sprintf('Authorization: Basic %s', base64_encode(sprintf('%s:%s', $clientId, $clientSecret)));
|
$headers[] = sprintf('Authorization: Basic %s', base64_encode(sprintf('%s:%s', $clientId, $clientSecret)));
|
||||||
|
|
||||||
|
if($scope !== '')
|
||||||
|
$body['scope'] = $scope;
|
||||||
|
|
||||||
$body = Tools::shuffleArray($body);
|
$body = Tools::shuffleArray($body);
|
||||||
$response = Tools::fetch($tokenUri, headers: $headers, body: $body);
|
$response = Tools::fetch($tokenUri, headers: $headers, body: $body);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue