Laravel 10 Passport -客户端身份验证失败- OAuthServerException

g6baxovj  于 2023-08-08  发布在  其他
关注(0)|答案(1)|浏览(230)

我已经启动了一个新的Laravel 10 REST API项目,并按照Laravel Passport文档中的说明设置了所有内容,但我遇到了以下错误。

"message": "There was some internal error",
    "result": null,
    "exception": {
        "message": "Client authentication failed",
        "file": "\/var\/www\/html\/vendor\/league\/oauth2-server\/src\/Exception\/OAuthServerException.php",
        "line": 154,
        "code": 4,
        "trace": [
            {
                "file": "\/var\/www\/html\/vendor\/league\/oauth2-server\/src\/Grant\/AbstractGrant.php",
                "line": 199,
                "function": "invalidClient",
                "class": "League\\OAuth2\\Server\\Exception\\OAuthServerException",
                "type": "::"
            },
            {
                "file": "\/var\/www\/html\/vendor\/laravel\/passport\/src\/Bridge\/PersonalAccessGrant.php",
                "line": 21,
                "function": "validateClient",
                "class": "League\\OAuth2\\Server\\Grant\\AbstractGrant",
                "type": "->"
            },
            {
                "file": "\/var\/www\/html\/vendor\/league\/oauth2-server\/src\/AuthorizationServer.php",
                "line": 201,
                "function": "respondToAccessTokenRequest",
                "class": "Laravel\\Passport\\Bridge\\PersonalAccessGrant",
                "type": "->"
            },

字符串
我的登录功能:

$credentials = $request->only(['email', 'password']);
        $validation = $this->validate($request, [
            'email' => 'required|email',
            'password' => 'required'
        ]);

        if (!auth()->attempt($credentials)) {
            return $this->apiResponse(
                [
                    'success' => false,
                    'message' => 'Unauthorized',
                    'alerts'=> ["type"=>"error","message"=>"Your Email address or Password is wrong"]
                ],
                401
            );
        }

        /* ------------ Create a new personal access token for the user. ------------ */
        $tokenData = auth()->user()->createToken('Personal Access Client');
        $token = $tokenData->accessToken;
        $expiration = $tokenData->token->expires_at->diffInSeconds(Carbon::now());


我已经重置了数据库并重新安装了Passport。我正在使用端口8001,我也已经将其设置为8000,因为我在某个地方读到它可能会起作用。

xsuvu9jc

xsuvu9jc1#

我也得到了同样的错误,我所做的是删除Passport::hashClientSecrets();在AuthServiceProvider的 Boot 方法中

相关问题