Skip to content

Commit cec763e

Browse files
committed
#15. Use Post method to generate OAuth token v2.
1 parent 79398ba commit cec763e

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/Client.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -273,13 +273,7 @@ public function setClientSecret($clientSecret)
273273
public function getAccessToken($code = '')
274274
{
275275
if (!empty($code)) {
276-
$uri = $this->buildUrl('accessToken', [
277-
'grant_type' => self::OAUTH2_GRANT_TYPE,
278-
self::OAUTH2_RESPONSE_TYPE => $code,
279-
'redirect_uri' => $this->getRedirectUrl(),
280-
'client_id' => $this->getClientId(),
281-
'client_secret' => $this->getClientSecret(),
282-
]);
276+
$uri = $this->buildUrl('accessToken', []);
283277
$guzzle = new GuzzleClient([
284278
'base_uri' => $this->getOAuthApiRoot(),
285279
'headers' => [
@@ -288,7 +282,13 @@ public function getAccessToken($code = '')
288282
],
289283
]);
290284
try {
291-
$response = $guzzle->get($uri);
285+
$response = $guzzle->post($uri, ['form_params' => [
286+
'grant_type' => self::OAUTH2_GRANT_TYPE,
287+
self::OAUTH2_RESPONSE_TYPE => $code,
288+
'redirect_uri' => $this->getRedirectUrl(),
289+
'client_id' => $this->getClientId(),
290+
'client_secret' => $this->getClientSecret(),
291+
]]);
292292
} catch (RequestException $exception) {
293293
throw Exception::fromRequestException($exception);
294294
}

0 commit comments

Comments
 (0)