Swashbuckle将Auth Bearer Token传递给API

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

Swashbuckle是否有关于如何将持有者令牌传递给API的任何文档,我无法在升级到最新的swashbuckle ver 2.1之后传递持有者令牌

swagger swashbuckle
1个回答
2
投票

我有blogged about this before

services.AddSwaggerGen(options =>
{
    options.AddSecurityDefinition("oauth2", new ApiKeyScheme
    {
        Description = "Standard Authorization header using the Bearer scheme. Example: \"bearer {token}\"",
        In = "header",
        Name = "Authorization",
        Type = "apiKey"
    });

    options.OperationFilter<SecurityRequirementsOperationFilter>();

你需要一份SecurityRequirementsOperationFilter,你可以通过谷歌搜索找到,或者从我的Swashbuckle.AspNetCore.Filters软件包安装。

© www.soinside.com 2019 - 2024. All rights reserved.