Skip to content

Commit

Permalink
bugfix: refresh_token is always access denied
Browse files Browse the repository at this point in the history
  • Loading branch information
G-YDG committed Mar 17, 2023
1 parent 9dbbb04 commit bb9d166
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
24 changes: 10 additions & 14 deletions src/Oauth/Oauth.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ class Oauth extends KwaixiaodianApi
public function accessToken($code, string $grant_type = 'code'): array
{
$config = $this->getConfig();
$response = $this->getHttpClient()->request('GET', $this->getBaseUri() . 'oauth2/access_token', [
'query' => [
'app_id' => $config['app_key'],
'app_secret' => $config['app_secret'],
'grant_type' => $grant_type,
'code' => $code,
],
$response = $this->getHttpClient()->get($this->getBaseUri() . 'oauth2/access_token', [
'app_id' => $config['app_key'],
'app_secret' => $config['app_secret'],
'grant_type' => $grant_type,
'code' => $code,
]);
return Utils::jsonResponseToArray($response);
}
Expand All @@ -38,13 +36,11 @@ public function accessToken($code, string $grant_type = 'code'): array
public function refreshToken($refresh_token): array
{
$config = $this->getConfig();
$response = $this->getHttpClient()->request('GET', $this->getBaseUri() . 'oauth2/refresh_token', [
'query' => [
'app_id' => $config['app_key'],
'app_secret' => $config['app_secret'],
'grant_type' => 'refresh_token',
'refresh_token' => $refresh_token,
],
$response = $this->getHttpClient()->post($this->getBaseUri() . 'oauth2/refresh_token', [
'grant_type' => 'refresh_token',
'refresh_token' => $refresh_token,
'app_id' => $config['app_key'],
'app_secret' => $config['app_secret'],
]);
return Utils::jsonResponseToArray($response);
}
Expand Down
2 changes: 2 additions & 0 deletions tests/Api/DistributionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@ public function testOpenDistributionCpsKwaimoneyLinkCreate()
'page' => 1,
'pageSize' => 1,
]);
$this->isSuccessResponse($pidListResult);
$pid = $pidListResult['data']['cpsPidData'][0];

$itemListResult = $app->distribution->openDistributionCpsKwaimoneySelectionItemList([
'pageIndex' => 1,
'pageSize' => 1,
'planType' => 1,
]);
$this->isSuccessResponse($itemListResult);
$item = $itemListResult['data']['itemList'][0];

$response = $app->distribution->openDistributionCpsKwaimoneyLinkCreate([
Expand Down

0 comments on commit bb9d166

Please sign in to comment.