Php 使用Codeception测试刷新令牌验证失败
我有一个phpleague/oauth2服务器实现,运行良好,即生成访问/刷新令牌、验证等 我有以下问题。当我使用grant_type=refresh_token和console curl刷新令牌时,我成功地获得了新的访问令牌,但在使用测试执行此操作时:Php 使用Codeception测试刷新令牌验证失败,php,curl,codeception,oauth2,Php,Curl,Codeception,Oauth2,我有一个phpleague/oauth2服务器实现,运行良好,即生成访问/刷新令牌、验证等 我有以下问题。当我使用grant_type=refresh_token和console curl刷新令牌时,我成功地获得了新的访问令牌,但在使用测试执行此操作时: $I->sendPOST('access_token', [ 'grant_type' => 'password', 'client_id' => '111', 'client_secret' =>
$I->sendPOST('access_token', [
'grant_type' => 'password',
'client_id' => '111',
'client_secret' => '222',
'username' => 'exampleuser',
'password' => 'examplepass',
]);
$I->seeResponseCodeIs(200);
$I->seeResponseContainsJson(['token_type' => 'Bearer']);
// I receive a proper string, checked that out
$token = $I->grabDataFromResponseByJsonPath('$.refresh_token')[0];
$I->sendPOST('access_token', [
'grant_type' => 'refresh_token',
'client_id' => 1,
'client_secret' => 'pass2',
'refresh_token' => $token
]);
$I->seeResponseCodeIs(200); // Here I receive 403
...
我重复一遍,在终端中手动执行此操作很好。
在亲自调试之后,我发现刷新令牌验证失败
在oauth2服务器/src/Grant/RefreshTokenGrant.php上,地址:
$refreshToken = $this->decrypt($encryptedRefreshToken);
但我仍然不明白为什么它是手动工作的。我做了urlencode/urldecode和大量的var转储,但仍然无法得到解决方案