laravel - 我用 GuzzleHttp 请求无法解决 PSR 请求错误
问题描述
在我的 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”提供了哪些值?这可能是问题吗?
如何解决此错误?
谢谢!
解决方案
在提供程序应用程序上安装包 nyholm/psr7 解决了这个问题!
推荐阅读
- jenkins - Jenkins 声明式管道记录一条在 Blue Ocean 中可见的警告消息
- json - pyspark - 读取 json 文件
- angular - 如何使用 Observable 存储状态管理以角度实现反应式编程?
- javascript - 如果对象数组中的值为假,如何返回具有布尔值的函数?
- javascript - Gulpfile 不适用于 import X from './X' statements
- security - SoftHSM V2 库文件?
- reactjs - React Material UI 条件渲染表格单元格颜色
- postgresql - repmgr 中未发生自动故障转移
- regex - 如何使用正则表达式查找给定单词之前是否存在单词?
- python-3.x - 无法为以前工作的脚本运行 pd.read_excel