title: InvalidOperationException: No authenticationScheme was specified, and there was no DefaultChallengeScheme found. (.net core 5)
body: <p>I use .net 5 web api to create my application.
  I put [Authorize] top of my controller.
  I use Identityserver4 as auth-server.(localhost:5000)
  and here is my startup.cs class:</p>
  <pre><code> public class Startup
  {
      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.AddControllers();
          services.AddDbContext&lt;MyContext&gt;(opts =&gt;
              opts.UseInMemoryDatabase(&quot;MyDb&quot;));
  
          services.AddAuthentication(&quot;bearer&quot;)
              .AddIdentityServerAuthentication(opts =&gt;
              {
                  opts.Authority = &quot;http://locallhost:5000&quot;;
                  opts.RequireHttpsMetadata = false;
                  opts.ApiName = &quot;myApi&quot;;
              });
          services.AddSwaggerGen(c =&gt;
          {
              c.SwaggerDoc(&quot;v1&quot;, new OpenApiInfo { Title = &quot;CustomerApi&quot;, Version = &quot;v1&quot; });
          });
  
      }
  
  
      public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
      {
          if (env.IsDevelopment())
          {
              app.UseDeveloperExceptionPage();
              app.UseSwagger();
              app.UseSwaggerUI(c =&gt; c.SwaggerEndpoint(&quot;/swagger/v1/swagger.json&quot;, &quot;CustomerApi v1&quot;));
          }
  
          app.UseAuthentication();
          app.UseRouting();
          app.UseAuthorization();
          app.UseEndpoints(endpoints =&gt;
          {
              endpoints.MapControllers();
          });
      }
  }
  </code></pre>
  <p>but I get below error:
  <a href="https://i.stack.imgur.com/EaZAH.png" rel="nofollow noreferrer">error</a></p>
  <p>please guide me to resolve my problem.
  I search much time but the answers is for .net 3.1 .</p>