title: Getting 401 unauthorized ASP.NET CORE 6
body: <p>Im implementing role based authentication in ASP.NET CORE 6, and im getting 401 Unauthorized from Postman. i have included the bearer token, i have checked it in jwt.io and it is valid. but it still shows up 401 unauthorized. here is my startup.cs file</p>
  <pre><code>builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
      .AddJwtBearer(options =&gt;
      {
          options.TokenValidationParameters = new TokenValidationParameters
          {
              ValidateIssuerSigningKey = true,
              IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(builder.Configuration.GetSection(&quot;AppSettings:Token&quot;).Value)),
              ValidateIssuer = false,
              ValidateAudience = false
          };
      });
  builder.Services.AddControllersWithViews();
  builder.Services.AddRazorPages();
  
  var app = builder.Build();
  
  // Configure the HTTP request pipeline.
  if (app.Environment.IsDevelopment())
  {
      app.UseWebAssemblyDebugging();
  }
  else
  {
      app.UseExceptionHandler(&quot;/Error&quot;);
      // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
      app.UseHsts();
  }
  
  app.UseHttpsRedirection();
  
  app.UseBlazorFrameworkFiles();
  app.UseStaticFiles();
  
  app.MapRazorPages();
  
  app.UseAuthentication();
  app.UseRouting();
  app.UseAuthorization();
  
  app.MapControllers();
  app.MapFallbackToFile(&quot;index.html&quot;);
  
  app.Run();
  </code></pre>
  <p>and here is a controller method</p>
  <pre><code>[HttpGet(&quot;onlinedrivers&quot;), Authorize]
  
  public async Task&lt;ActionResult&gt; GetOnlineDrivers()
  {
      var result = await _driverServices.GetOnlineDrivers();
      return Ok(result);
  }
  </code></pre>
  <p>i included the jwt bearer token as follows
  <a href="https://i.stack.imgur.com/Jlapa.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Jlapa.jpg" alt="Token included" /></a></p>
  <p>i dont know what im doing wrong</p>