laravel - invalid_grant 用于密码 grant_type Laravel Passport
问题描述
我正在尝试为我的 API 创建一个 access_token,但我遇到了显示此消息的问题:
"error": "invalid_client",
"error_description": "Client authentication failed",
"message": "Client authentication failed"
这是我的请求数据:
{
"username":"neal.jacobi@example.org",
"password":"test1234",
"grant_type":"password",
"client_id": "2",
"client_secret":"jScq3DMMeZctypnYb7f1ClEHyzybwTK1Yisqo09E"
}
这是我的 oauth_clients 表:
解决方案
您需要在请求正文中发送以下内容。
{
"username":"neal.jacobi@example.org",
"password":"test1234",
"grant_type":"password",
"client_id": "2",
"client_secret":"jScq3DMMeZctypnYb7f1ClEHyzybwTK1Yisqo09E"
}
正在通过以下方法从请求正文验证客户端凭据。
// League\OAuth2\Server\Grant\AbstractGrant
// line 253
protected function getClientCredentials(ServerRequestInterface $request)
{
[$basicAuthUser, $basicAuthPassword] = $this->getBasicAuthCredentials($request);
$clientId = $this->getRequestParameter('client_id', $request, $basicAuthUser); // It is fetching from request body
if (\is_null($clientId)) {
throw OAuthServerException::invalidRequest('client_id');
}
$clientSecret = $this->getRequestParameter('client_secret', $request, $basicAuthPassword);
if ($clientSecret !== null && !\is_string($clientSecret)) {
throw OAuthServerException::invalidRequest('client_secret');
}
return [$clientId, $clientSecret];
}
推荐阅读
- css - 将文本垂直对齐到 Flexbox 上的 div 顶部
- javascript - 反应上下文:初始化之前无法访问“AuthContext”
- laravel - 在 octobercms 中创建新表
- facebook - Facebook Limited 登录并在会话之间保留访问令牌
- database - 是否可以使用 BASE-fashioned 数据库实现 Exacly Once Semantics?
- sql - 数字数据类型 oracle 的默认值的正确格式
- laravel - laravel 集体选择的默认值
- javascript - 过渡不适用于 div - vanilla js 手风琴
- regex - 赛普拉斯断言失败,包含方法的正则表达式
- firebase - 使用 Firebase 函数创建、访问和读取日志的最佳方式