我无法使用GuzzleHttp请求解决PSR请求错误

时间:2020-04-30 05:00:22

标签: laravel guzzlehttp

在我的Laravel 7.6应用程序(本地主机http://local-votes.com上的pt主机)api中实现 我想从其他API发出测试请求 Laravel 6.17.1应用程序,请在此处阅读:https://laravel.com/docs/7.x/passport 转换授权码以访问令牌

我尝试使用以下示例:

        $http = new \GuzzleHttp\Client;

        $client_id= 3;  // client ID I made in my host app
        $client_secret= 'XXX'; // client secret I made in my host app

        $host= 'http://local-votes.com';
        $response = $http->post($host.'/oauth/token', [
            'form_params' => [
                'grant_type' => 'authorization_code',
                'client_id' => $client_id,
                'client_secret' => $client_secret,
                'redirect_uri' => $host.'/votes',
                'code' => 'code',
//                'code' => $request->code,
            ],
        ]);

但是我遇到了错误:

Illuminate\Contracts\Container\BindingResolutionException: Unable to resolve PSR request. Please i (truncated...)
 {"userId":5,"exception":"[object] (GuzzleHttp\\Exception\\ServerException(code: 500): Server error: `POST http://local-votes.com/oauth/token` resulted in a `500 Internal Server Error` response:

我也不确定为字段“ client_secret”和“ code”提供哪些值? 可能是问题吗?

如何解决此错误?

谢谢!

1 个答案:

答案 0 :(得分:0)

安装软件包nyholm / psr7 提供程序应用程序上的问题解决了!