Skip to content

Commit 304394d

Browse files
authored
Merge pull request #62 from chadicus/v3.x
Fix full URL issue in createApiGatewayClientCredentials
2 parents 503042e + 52691de commit 304394d

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

src/Authentication.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -141,32 +141,29 @@ public static function createOwnerCredentials(
141141
/**
142142
* Creates a new instance of Authentication for Client Credentials grant type
143143
*
144-
* @param string $clientId The oauth client id
145-
* @param string $clientSecret The oauth client secret
146-
* @param string $authUrl The oauth auth url
147-
* @param string $tokenResource The access token resource of the API
144+
* @param string $clientId The oauth client id
145+
* @param string $clientSecret The oauth client secret
146+
* @param string $authUrl The oauth auth url
148147
*
149148
* @return Authentication
150149
*/
151150
public static function createApiGatewayClientCredentials(
152151
string $clientId,
153152
string $clientSecret,
154-
string $authUrl,
155-
string $tokenResource = 'token'
153+
string $authUrl
156154
) : Authentication {
157155
$getTokenRequestFunc = function (
158156
string $unusedBaseUrl,
159157
string $unusedRefreshToken = null
160158
) use (
161159
$clientId,
162160
$clientSecret,
163-
$authUrl,
164-
$tokenResource
161+
$authUrl
165162
) {
166163
$data = ['client_id' => $clientId, 'client_secret' => $clientSecret, 'grant_type' => 'client_credentials'];
167164
return new Request(
168165
'POST',
169-
"{$authUrl}/oauth2/{$tokenResource}",
166+
$authUrl,
170167
['Content-Type' => 'application/x-www-form-urlencoded'],
171168
Http::buildQueryString($data)
172169
);

tests/AuthenticationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ public function getTokenRequestApiGatewayClientCredentials()
186186
{
187187
$auth = Authentication::createApiGatewayClientCredentials('id', 'secret', 'authUrl');
188188
$request = $auth->getTokenRequest('baseUrl');
189-
$this->assertSame('authUrl/oauth2/token', (string)$request->getUri());
189+
$this->assertSame('authUrl', (string)$request->getUri());
190190
$this->assertSame('POST', $request->getMethod());
191191
$this->assertSame(
192192
'client_id=id&client_secret=secret&grant_type=client_credentials',

0 commit comments

Comments
 (0)