带有laravel-passport的Swagger API身份验证

时间:2019-07-22 13:28:15

标签: php laravel swagger laravel-passport

我正在使用swagger记录使用Laravel 5.8构建的API应用程序。我还使用Passport进行API身份验证,并尝试在文档中实现它。

当我尝试授权用户使用招摇工具时,我在这里收到错误消息

  

auth errorTypeError:尝试获取资源时出现NetworkError。

这就是我如何设置它的方法

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_secretoauth_clients

身份验证是如何完成的?我做了什么不同的事情?

0 个答案:

没有答案