Php Laravel 5.8护照“;导致“401未经授权”;

Php Laravel 5.8护照“;导致“401未经授权”;,php,laravel,Php,Laravel,我对我的laravel 5.8项目有意见 我想用passport和Guzzle进行注册并获得代币,但当我发布一条新记录以获得代币时,我得到了一个错误提示 "`POST http://femlife.test/oauth/token` resulted in a `401 Unauthorized` response: {"error":"invalid_credentials","error_description":&quo

我对我的laravel 5.8项目有意见

我想用passport和Guzzle进行注册并获得代币,但当我发布一条新记录以获得代币时,我得到了一个错误提示

"`POST http://femlife.test/oauth/token` resulted in a `401 Unauthorized` response:
{"error":"invalid_credentials","error_description":"The user credentials were incorrect.","message":"The user credential (truncated...)"
这是我的密码:

$http=新客户端

    $response = $http->post('http://femlife.test/oauth/token', [
        'form_params' => [
            'grant_type' => 'password',
            'client_id' => 2,
            'client_secret' => 'gpnQCoxmAxeiW8srk50j5onLiwvRs3dc8aiID3S3',
            'username' => $request->name,
            'password' => $request->password,
            'scope' => '',
            'code' => 200,
            'redirect_uri' => 'http://localhost'
        ],
    ]);

    return response(['data'=>json_decode((string) $response->getBody(), true)]);

拜托,我做错什么了?我看到一些建议,我必须将服务器实例和客户端实例分开,因为现在我使用一个XAMPP实例。

在这一行中:

'username' => $request->name,

您可能用错误的值设置用户名。确保您的用户名字段名正确。

似乎不起作用!我甚至将$request->name替换为一个本该有效的字符串。。。但不是!