Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

setup authorize in swagger .net core

services.AddSwaggerGen(c =>
  {
    c.SwaggerDoc("v1", new Info { Title = "You api title", Version = "v1" });
    c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
      {
        Description = @"JWT Authorization header using the Bearer scheme. 

 
                      Enter 'Bearer' [space] and then your token in the text input below.
                      

Example: 'Bearer 12345abcdef'",
         Name = "Authorization",
         In = ParameterLocation.Header,
         Type = SecuritySchemeType.ApiKey,
         Scheme = "Bearer"
       });

    c.AddSecurityRequirement(new OpenApiSecurityRequirement()
      {
        {
          new OpenApiSecurityScheme
          {
            Reference = new OpenApiReference
              {
                Type = ReferenceType.SecurityScheme,
                Id = "Bearer"
              },
              Scheme = "oauth2",
              Name = "Bearer",
              In = ParameterLocation.Header,

            },
            new List<string>()
          }
        });
    var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
    var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
    c.IncludeXmlComments(xmlPath);
});
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# random boolean 
Csharp :: c# int input 
Csharp :: get text between two strings c# 
Csharp :: c# if debug 
Csharp :: c# resize image keep aspect ratio 
Csharp :: unity textmesh pro 
Csharp :: windows form rounded corners 
Csharp :: unity check when clicked on object 
Csharp :: wait in unity 
Csharp :: c# get script directory 
Csharp :: c# print all property values of object 
Csharp :: c# reverse string 
Csharp :: get datacontext of parent wpf 
Csharp :: remove a specific line in richtextbox c# 
Csharp :: unity get project file directory 
Csharp :: c# datediff minutes 
Csharp :: unity time.deltatime timescale 0 
Csharp :: c# application hangs while running 
Csharp :: get apps execution path with app name c# 
Csharp :: Unity Scene Load by Name 
Csharp :: set ads for children admob unity 
Csharp :: c# determine configration at runtime 
Csharp :: how to make a quit button in unity 
Csharp :: c# get property using string 
Csharp :: C# define a block as text 
Csharp :: shorthand in c# operator 
Csharp :: remove character from string c# 
Csharp :: c# ascii to char 
Csharp :: unity set text value 
Csharp :: c# separate string by comma 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =