Skip to content

Abdullah-onGit/AuthorizationSettingsInSwagger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WebApplication3

https://dev.to/eduardstefanescu/aspnet-core-swagger-documentation-with-bearer-authentication-40l6 https://www.infoworld.com/article/3650668/implement-authorization-for-swagger-in-aspnet-core-6.html

builder.Services.AddSwaggerGen(option => { option.SwaggerDoc("v1", new OpenApiInfo { Title = "Demo API", Version = "v1" }); option.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme { In = ParameterLocation.Header, Description = "Please enter a valid token", Name = "Authorization", Type = SecuritySchemeType.Http, BearerFormat = "JWT", Scheme = "Bearer" }); option.AddSecurityRequirement(new OpenApiSecurityRequirement { { new OpenApiSecurityScheme { Reference = new OpenApiReference { Type=ReferenceType.SecurityScheme, Id="Bearer" } }, new string[]{} } }); });

About

Authorization Settings In Swagger

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages