Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/258.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用laravel passport进行Swagger API身份验证_Php_Laravel_Swagger_Laravel Passport - Fatal编程技术网

Php 使用laravel passport进行Swagger API身份验证

Php 使用laravel passport进行Swagger API身份验证,php,laravel,swagger,laravel-passport,Php,Laravel,Swagger,Laravel Passport,我正在使用swagger为使用Laravel5.8构建的API应用程序编写文档。我还使用Passport进行API身份验证,并尝试在文档中实现它 当我试图在swagger上授权用户时,我在这里得到了错误 auth errorTypeError:尝试获取资源时出现NetworkError 下面是我如何设置它的招摇过市 在l5 swagger.phpconfig文件中 /* Open API 3.0 support */ 'passport' => [ // Unique name of se

我正在使用swagger为使用Laravel5.8构建的API应用程序编写文档。我还使用Passport进行API身份验证,并尝试在文档中实现它

当我试图在swagger上授权用户时,我在这里得到了错误

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

下面是我如何设置它的招摇过市

l5 swagger.php
config文件中

/* 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(...),
* )
*/
这是swagger授权屏幕的图像

我从
oauth\u clients
表中获取
client\u id
client\u secret


身份验证是如何完成的,我的做法有什么不同?

浏览器开发工具控制台选项卡上的错误消息是什么?只是一个警告
跨源请求被阻止:同源策略不允许在http://localhost/oauth/token. (原因:CORS标题“访问控制允许原点”缺失)
。虽然我已经为项目启用了cors,web和mobile都能够成功连接Swagger UI运行的主机和端口是什么?如果运行
curl-X选项http://localhost/oauth/token --详细
,响应是否具有
访问控制允许来源
标题?它在端口80上的Bluehost VPS上运行。响应没有
访问控制允许源站
标题栏,如CORS未正确设置。