登录时我总是得到无效的授权类型。我使用的是 Laravel 7 和护照 8.4。
我可以通过运行 php artisan passport:install 确认我创建了 client_secret 没有错误,但我找不到任何可能为什么获取访问令牌和刷新令牌不起作用。
$credentials = [
'grant_type' => 'password',
'client_id' => '2',
'client_secret' => 'zcdHbITBhD5PPgGZ4n8qpIgYmmK83hcdYTbvLmja',
'username' => $email,
'password' => $password,
'scope' => '*',
];
$request = Request::create('oauth/token', 'POST', $credentials, [], [], [
'HTTP_Accept' => 'application/json',
'Content-type' => 'application/x-www-form-urlencoded'
]);
$response = app()->handle($request);
//$response = app('router')->prepareResponse($request, app()->handle($request));
$decodedResponse = json_decode($response->getContent(), true);
// if ($response->getStatusCode() != 200) {
我正在使用在配置中正确设置的自定义用户提供程序,并且我注意到如果我将 grant_type 更改为“client_credentials”,它将正常工作,但没有我想要的刷新令牌。
有任何想法吗 ?