php - 使用 laravel-passport 进行 Swagger API 身份验证
问题描述
我正在使用 swagger 来记录使用 Laravel 5.8 构建的 API 应用程序。我还在使用 Passport 进行 API 身份验证,并尝试在文档中实现它。
当我尝试在 swagger 上授权用户时,我在此处收到错误
auth errorTypeError:尝试获取资源时出现网络错误。
这就是我如何设置它
在l5-swagger.php
配置文件中
/* Open API 3.0 support */
'passport' => [ // Unique name of security
'type' => 'oauth2', // The type of the security scheme. Valid values are "basic", "apiKey" or "oauth2".
'description' => 'Laravel passport oauth2 security.',
'in' => 'header',
'scheme' => 'https',
'flows' => [
"password" => [
"authorizationUrl" => config('app.url') . '/oauth/authorize',
"tokenUrl" => config('app.url') . '/oauth/token',
"refreshUrl" => config('app.url') . '/token/refresh',
"scopes" => []
],
],
],
在控制器中,我有招摇的代码
/**
* @OA\Get(
* path="/products/{product}",
* tags={"Product"},
* description="Gets specified product",
* operationId="getProductById",
* summary="Fetches a product by the product Id",
* security={{"passport": {}}},
* @OA\Parameter(...),
* @OA\Response(...),
* )
*/
这是招摇授权屏幕的图像
https://i.stack.imgur.com/aiYjs.png
我从桌子上得到client_id
& 。client_secret
oauth_clients
身份验证是如何完成的,我有什么不同的做法?
解决方案
推荐阅读
- python - 从python中的元组字典编写excel
- python - 大型稀疏线性系统求解,重排序和预处理器更糟?
- c# - C# LINQ to entity 计算嵌套表中的项目
- nginx - 我可以匹配 nginx 中的 www 文件夹结构吗?
- pycharm - 如何同步 pycharm venv 解释器的 requirements.txt?
- haskell - IORef 的内存占用和性能
- ruby-on-rails - 活动存储(存储在 AWS S3 中)移动上传的图像在 safari 上旋转
- mysql - 如果连接断开,如何在 nodejs 的 promise-mysql 中使用 Pool 重新连接?
- r - 如何为 R 中的 nnet 分类/预测准备变量?
- c++ - Visual Studio 2019 CVT1101 & LNK1123 致命错误