0Pricing
C# Academy · Lesson

Configuring JWT Bearer Authentication

Wire up token validation in the pipeline.

The JWT Bearer Handler

ASP.NET Core validates incoming JWTs using the JWT Bearer authentication handler from the Microsoft.AspNetCore.Authentication.JwtBearer package.

It reads the token from the Authorization: Bearer ... header, validates it, and builds a ClaimsPrincipal.

dotnet add package Microsoft.AspNetCore.Authentication.JwtBearer

AddAuthentication

Registration starts with AddAuthentication. You set the default scheme so the framework knows which handler to use when no scheme is specified.

JwtBearerDefaults.AuthenticationScheme is the string "Bearer".

builder.Services
    .AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
    .AddJwtBearer();

All lessons in this course

  1. JWT Structure and Claims
  2. Configuring JWT Bearer Authentication
  3. Issuing Tokens
  4. Refresh Tokens and Expiry
← Back to C# Academy