Skip to main content
net9.0

ASP.NET Core middleware that enables an application to receive an OpenID Connect bearer token. This package was built from the source code at https://github.com/dotnet/aspnetcore/tree/209bf5cfd6f0b329c31faa125790e1d1d820cdb5

Published
Aug 11, 2026
2mo ago
Total Downloads
1.4B
1,362,566,926

Install

dotnet add package Microsoft.AspNetCore.Authentication.JwtBearer --version 9.0.19
ProductVersions
.NET
net9.0

README

About

Microsoft.AspNetCore.Authentication.JwtBearer is a middleware component designed for ASP.NET Core applications. It facilitates JSON Web Token (JWT) authentication, enabling secure authentication for APIs and web services. This package allows you to validate JWT tokens issued by an authentication server, ensuring secure access to your application's resources.

Key Features

  • Seamless integration with ASP.NET Core applications.
  • Supports JSON Web Token (JWT) authentication.
  • Enables secure authentication for APIs and web services.
  • Flexible configuration options for token validation parameters.
  • Works with .NET Core 3.0 and newer, as well as .NET Standard 2.1.

How to Use

using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.IdentityModel.Tokens;
using System.Text;

public void ConfigureServices(IServiceCollection services)
{
    services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
        .AddJwtBearer(options =>
        {
            options.TokenValidationParameters = new TokenValidationParameters
            {
                ValidateIssuer = true,
                ValidateAudience = true,
                ValidateLifetime = true,
                ValidateIssuerSigningKey = true,
                ValidIssuer = "your_issuer",
                ValidAudience = "your_audience",
                IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes("your_secret_key"))
            };
        });

    // Other configurations...
}

For more detailed configuration options and advanced scenarios, please refer to the blog JWT Validation and Authorization in ASP.NET Core.

Main Types

The main types provided by this library are:

  • JwtBearerDefaults: Contains default values for JWT Bearer authentication.
  • JwtBearerEvents: Events used to handle JWT Bearer authentication events.
  • JwtBearerHandler: Handles JWT Bearer authentication requests.
  • wtBearerOptions: Options for configuring JWT Bearer authentication.

Additional Documentation

Feedback & Contributing

Microsoft.AspNetCore.Authentication.JwtBearer is released as open-source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.

Changes from Previous Version

No structural changes between v9.0.18 and v9.0.19.

Adoption Assessment

Resource APIs that need standards-based token validation and policy-driven authorization.

Security Guide
Compatibility metadata lists 1 target framework; confirm the exact target used by your application.
Editorial Note: JWT bearer authentication middleware for validating access tokens in ASP.NET Core APIs. Trade-off: You still need robust issuer configuration, key rollover handling and defense-in-depth authorization rules.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.