Swagger Auth使用用户名和密码.netcore 2

问题描述 投票:1回答:1

我有mvc webapi .netcore 2,并向我的应用程序添加了招摇使开发人员测试操作但是动作已测试过[授权]属性,因此单击时需要通过用户名和密码进行授权授权按钮,显示在swagger index.html页面中,如锅炉板应用程序中所示enter image description here

输入用户名和密码并单击登录后,我可以使用需要授权的任何操作,我该如何做为样板的图像

c# asp.net-core .net-core asp.net-core-mvc swagger
1个回答
0
投票

有一个小教程,我发现herehere您可以尝试]]

基本上使用AddSecurityDefinition

           c.AddSecurityDefinition("Bearer", new ApiKeyScheme
            {
                Description = "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\"",
                Name = "Authorization",
                In = "header",
                Type = "apiKey"
            });
© www.soinside.com 2019 - 2024. All rights reserved.