title: Authorization Bearer token not being sent in request using Swagger in Asp.Net Core
body: <p>I am using Swagger to test my APIs in the Asp.Net Core application. I am sending the request using by entering the token like this <code>Authorization: Bearer {token}</code>. but the Authorization header is not being sent in requests.</p>
  
  <p>Asp.Net Core version 3.1 and Swashbuckle.AspNetCore 5.4.1</p>
  
  <p><strong>Startup.cs Code:</strong></p>
  
  <pre><code>public class Startup
  {
      private const string _apiVersion = "v1";
      public Startup(IConfiguration configuration)
      {
          Configuration = configuration;
      }
  
      public IConfiguration Configuration { get; }
  
      // This method gets called by the runtime. Use this method to add services to the container.
      public void ConfigureServices(IServiceCollection services)
      {
          services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
              .AddJwtBearer(options =&gt;
              {
                  options.TokenValidationParameters = new TokenValidationParameters
                  {
                      ClockSkew = TimeSpan.FromMinutes(0),
                      ValidateIssuer = true,
                      ValidateAudience = true,
                      ValidateLifetime = true,
                      ValidateIssuerSigningKey = true,
                      ValidIssuer = Configuration["Jwt:Issuer"],
                      ValidAudience = Configuration["Jwt:Issuer"],
                      IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Configuration["Jwt:Key"]))
                  };
              });
  
  
          services.AddSwaggerGen(options =&gt;
          {
              options.SwaggerDoc("v1", new OpenApiInfo
              {
                  Version = "v1",
                  Title = "MyProject API",
                  Description = "MyProject"
              });
              options.DocInclusionPredicate((docName, description) =&gt; true);
  
              // Define the BearerAuth scheme that's in use
              options.AddSecurityDefinition("bearerAuth", new OpenApiSecurityScheme()
              {
                  Description = "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\"",
                  Name = "Authorization",
                  In = ParameterLocation.Header,
                  Type = SecuritySchemeType.ApiKey
              });
          });
  
      }
  
      // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
      public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
      {
          app.UseAuthentication();
          loggerFactory.AddLog4Net();
  
          if (env.IsDevelopment())
          {
              app.UseDeveloperExceptionPage();
          }
  
          app.UseRouting();
  
          app.UseAuthorization();
  
          app.UseEndpoints(endpoints =&gt;
          {
              endpoints.MapControllers();
          });
  
          // Enable middleware to serve generated Swagger as a JSON endpoint
          app.UseSwagger(c =&gt; { c.RouteTemplate = "swagger/{documentName}/swagger.json"; });
  
          // Enable middleware to serve swagger-ui assets (HTML, JS, CSS etc.)
          app.UseSwaggerUI(options =&gt;
          {
              // specifying the Swagger JSON endpoint.
              options.SwaggerEndpoint($"/swagger/{_apiVersion}/swagger.json", $"MyProject API {_apiVersion}");
              //options.IndexStream = () =&gt; Assembly.GetExecutingAssembly()
              //    .GetManifestResourceStream("MyProject.Web.Host.wwwroot.swagger.ui.index.html");
              options.DisplayRequestDuration(); // Controls the display of the request duration (in milliseconds) for "Try it out" requests.  
          }); // URL: /swagger
      }
  }
  </code></pre>