Skip to content
Merged
Show file tree
Hide file tree
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
15 changes: 6 additions & 9 deletions src/Authentication.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,32 +141,29 @@ public static function createOwnerCredentials(
/**
* Creates a new instance of Authentication for Client Credentials grant type
*
* @param string $clientId The oauth client id
* @param string $clientSecret The oauth client secret
* @param string $authUrl The oauth auth url
* @param string $tokenResource The access token resource of the API
* @param string $clientId The oauth client id
* @param string $clientSecret The oauth client secret
* @param string $authUrl The oauth auth url
*
* @return Authentication
*/
public static function createApiGatewayClientCredentials(
string $clientId,
string $clientSecret,
string $authUrl,
string $tokenResource = 'token'
string $authUrl
) : Authentication {
$getTokenRequestFunc = function (
string $unusedBaseUrl,
string $unusedRefreshToken = null
) use (
$clientId,
$clientSecret,
$authUrl,
$tokenResource
$authUrl
) {
$data = ['client_id' => $clientId, 'client_secret' => $clientSecret, 'grant_type' => 'client_credentials'];
return new Request(
'POST',
"{$authUrl}/oauth2/{$tokenResource}",
$authUrl,
['Content-Type' => 'application/x-www-form-urlencoded'],
Http::buildQueryString($data)
);
Expand Down
2 changes: 1 addition & 1 deletion tests/AuthenticationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public function getTokenRequestApiGatewayClientCredentials()
{
$auth = Authentication::createApiGatewayClientCredentials('id', 'secret', 'authUrl');
$request = $auth->getTokenRequest('baseUrl');
$this->assertSame('authUrl/oauth2/token', (string)$request->getUri());
$this->assertSame('authUrl', (string)$request->getUri());
$this->assertSame('POST', $request->getMethod());
$this->assertSame(
'client_id=id&client_secret=secret&grant_type=client_credentials',
Expand Down
Loading