首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用于密码grant_type Laravel Passport的invalid_grant

用于密码grant_type Laravel Passport的invalid_grant
EN

Stack Overflow用户
提问于 2021-09-23 00:29:16
回答 2查看 68关注 0票数 1

我正在尝试为我的应用程序接口创建一个access_token,但我遇到了显示以下消息的问题:

代码语言:javascript
复制
"error": "invalid_client",
"error_description": "Client authentication failed",
"message": "Client authentication failed"

这是我的请求数据:

代码语言:javascript
复制
{
  "username":"neal.jacobi@example.org",
  "password":"test1234",
  "grant_type":"password",
  "client_id": "2",
  "client_secret":"jScq3DMMeZctypnYb7f1ClEHyzybwTK1Yisqo09E"
}

这是我的oauth_clients表:

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2021-09-23 01:49:09

您尝试在请求数据中添加scope

代码语言:javascript
复制
{
  "username":"neal.jacobi@example.org",
  "password":"test1234",
  "grant_type":"password",
  "client_id": "2",
  "client_secret":"jScq3DMMeZctypnYb7f1ClEHyzybwTK1Yisqo09E",
  "scope" => ""
}

如果你有什么问题,请告诉我。

票数 0
EN

Stack Overflow用户

发布于 2021-09-23 00:55:03

您需要在请求正文中发送以下内容。

代码语言:javascript
复制
{
  "username":"neal.jacobi@example.org",
  "password":"test1234",
  "grant_type":"password",
  "client_id": "2",
  "client_secret":"jScq3DMMeZctypnYb7f1ClEHyzybwTK1Yisqo09E"
}

客户端凭据将通过以下方法从请求正文进行验证。

代码语言:javascript
复制
// 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];
    }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69292624

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档