Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

swagger authentication bearer .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 :: asp.net list all files in folder 
Csharp :: open new window c# wpf 
Csharp :: how to change the extension of a file C# 
Csharp :: find unity 
Csharp :: c# empty char 
Csharp :: remap float c# 
Csharp :: c# json to dictionary 
Csharp :: c# convert string to char array 
Csharp :: unity array to list 
Csharp :: how to change rotate with script unity 
Csharp :: how to get executable path in wpf 
Csharp :: c# double value with 2 decimal places 
Csharp :: c# get file extension 
Csharp :: assign datasource to dropdownlist in c# 
Csharp :: currentTimeMillis c# 
Csharp :: UnityEngine.Transform.get_position () (at <a0ef933b1aa54b668801ea864e4204fe:0) Gamekit3D.MeleeWeapon.BeginAttack (System.Boolean thowingAttack) 
Csharp :: .net loop through dictionary 
Csharp :: c# convert to snake case 
Csharp :: Request.ServerVariables["HTTP_X_FORWARDED_FOR"] get only one ipaddress 
Csharp :: unity agent walks in place at start 
Csharp :: hello in c# 
Csharp :: csharp datetime string format 
Csharp :: struct constructor c# 
Csharp :: convert int to string in linq query c# 
Csharp :: solution to fizzbuzz c# 
Csharp :: console writeline unity c# 
Csharp :: get logged in user name c# 
Csharp :: what type of variable is true or false in c# 
Csharp :: rigidbody.addtorque 
Csharp :: unity cast float to int 
ADD CONTENT
Topic
Content
Source link
Name
5+5 =