Microsoft.AspNetCore.Authentication.JwtBearer 9.0.0

Prefix Reserved
dotnet add package Microsoft.AspNetCore.Authentication.JwtBearer --version 9.0.0                
NuGet\Install-Package Microsoft.AspNetCore.Authentication.JwtBearer -Version 9.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="9.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Microsoft.AspNetCore.Authentication.JwtBearer --version 9.0.0                
#r "nuget: Microsoft.AspNetCore.Authentication.JwtBearer, 9.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Microsoft.AspNetCore.Authentication.JwtBearer as a Cake Addin
#addin nuget:?package=Microsoft.AspNetCore.Authentication.JwtBearer&version=9.0.0

// Install Microsoft.AspNetCore.Authentication.JwtBearer as a Cake Tool
#tool nuget:?package=Microsoft.AspNetCore.Authentication.JwtBearer&version=9.0.0                

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.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2.7K)

Showing the top 5 NuGet packages that depend on Microsoft.AspNetCore.Authentication.JwtBearer:

Package Downloads
Microsoft.Identity.Web.TokenAcquisition

Implementation for higher level API for confidential client applications (ASP.NET Core and SDK/.NET).

Microsoft.AspNetCore.App

Provides a default set of APIs for building an ASP.NET Core application. This package requires the ASP.NET Core runtime. This runtime is installed by the .NET Core SDK, or can be acquired separately using installers available at https://aka.ms/dotnet-download.

Microsoft.AspNetCore.All

Provides a default set of APIs for building an ASP.NET Core application, and also includes API for third-party integrations with ASP.NET Core. This package requires the ASP.NET Core runtime. This runtime is installed by the .NET Core SDK, or can be acquired separately using installers available at https://aka.ms/dotnet-download.

Microsoft.AspNetCore.Authentication.AzureAD.UI

ASP.NET Core Azure Active Directory Integration provides components for easily integrating Azure Active Directory authentication within your ASP.NET Core application. This package was built from the source code at https://github.com/dotnet/aspnetcore/tree/ab1f1c636afa3a6607f2d67bc387b586596d1d38

Okta.AspNetCore

Official Okta middleware for ASP.NET Core 3.1+. Easily add authentication and authorization to ASP.NET Core applications.

GitHub repositories (425)

Showing the top 5 popular GitHub repositories that depend on Microsoft.AspNetCore.Authentication.JwtBearer:

Repository Stars
bitwarden/server
Bitwarden infrastructure/backend (API, database, Docker, etc).
abpframework/abp
Open-source web application framework for ASP.NET Core! Offers an opinionated architecture to build enterprise software solutions with best practices on top of the .NET. Provides the fundamental infrastructure, cross-cutting-concern implementations, startup templates, application modules, UI themes, tooling and documentation.
dotnet/AspNetCore.Docs
Documentation for ASP.NET Core
duplicati/duplicati
Store securely encrypted backups in the cloud!
dotnet-architecture/eShopOnWeb
Sample ASP.NET Core 8.0 reference application, powered by Microsoft, demonstrating a layered application architecture with monolithic deployment model. Download the eBook PDF from docs folder.
Version Downloads Last updated
9.0.0 173,153 11/12/2024
9.0.0-rc.2.24474.3 56,355 10/8/2024
9.0.0-rc.1.24452.1 35,982 9/10/2024
9.0.0-preview.7.24406.2 8,247 8/13/2024
9.0.0-preview.6.24328.4 27,031 7/9/2024
9.0.0-preview.5.24306.11 5,708 6/11/2024
9.0.0-preview.4.24267.6 11,505 5/21/2024
9.0.0-preview.3.24172.13 79,620 4/11/2024
9.0.0-preview.2.24128.4 25,681 3/12/2024
9.0.0-preview.1.24081.5 26,164 2/13/2024
8.0.11 343,525 11/12/2024
8.0.10 3,538,445 10/8/2024
8.0.8 7,255,920 8/13/2024
8.0.7 5,837,702 7/9/2024
8.0.6 7,291,287 5/28/2024
8.0.5 2,716,011 5/14/2024
8.0.4 6,822,667 4/9/2024
8.0.3 4,938,192 3/12/2024
8.0.2 5,804,672 2/13/2024
8.0.1 7,091,175 1/9/2024
8.0.0 21,412,769 11/14/2023
8.0.0-rc.2.23480.2 404,440 10/10/2023
8.0.0-rc.1.23421.29 93,511 9/12/2023
8.0.0-preview.7.23375.9 178,214 8/8/2023
8.0.0-preview.6.23329.11 63,033 7/11/2023
8.0.0-preview.5.23302.2 11,306 6/13/2023
8.0.0-preview.4.23260.4 10,334 5/16/2023
8.0.0-preview.3.23177.8 16,724 4/11/2023
8.0.0-preview.2.23153.2 7,935 3/14/2023
8.0.0-preview.1.23112.2 59,237 2/21/2023
7.0.20 707,109 5/28/2024
7.0.19 104,942 5/14/2024
7.0.18 335,129 4/9/2024
7.0.17 358,422 3/12/2024
7.0.16 580,889 2/13/2024
7.0.15 1,026,129 1/9/2024
7.0.14 2,069,557 11/14/2023
7.0.13 2,392,557 10/24/2023
7.0.12 1,795,008 10/10/2023
7.0.11 2,616,667 9/12/2023
7.0.10 3,666,624 8/8/2023
7.0.9 2,681,759 7/11/2023
7.0.8 2,259,667 6/22/2023
7.0.7 1,190,305 6/13/2023
7.0.5 6,977,953 4/11/2023
7.0.4 3,458,970 3/14/2023
7.0.3 3,324,283 2/14/2023
7.0.2 4,165,218 1/10/2023
7.0.1 8,768,649 12/13/2022
7.0.0 5,086,893 11/7/2022
7.0.0-rc.2.22476.2 84,241 10/11/2022
7.0.0-rc.1.22427.2 23,553 9/14/2022
7.0.0-preview.7.22376.6 23,216 8/9/2022
7.0.0-preview.6.22330.3 220,725 7/12/2022
7.0.0-preview.5.22303.8 6,114 6/14/2022
7.0.0-preview.4.22251.1 10,369 5/10/2022
7.0.0-preview.3.22178.4 4,366 4/13/2022
7.0.0-preview.2.22153.2 3,876 3/14/2022
7.0.0-preview.1.22109.13 3,322 2/17/2022
6.0.36 36,024 11/12/2024
6.0.35 182,555 10/8/2024
6.0.33 617,601 8/13/2024
6.0.32 547,979 7/9/2024
6.0.31 722,684 5/28/2024
6.0.30 357,659 5/14/2024
6.0.29 1,135,111 4/9/2024
6.0.28 1,024,107 3/12/2024
6.0.27 1,307,561 2/13/2024
6.0.26 2,491,023 1/9/2024
6.0.25 3,290,979 11/14/2023
6.0.24 1,987,122 10/24/2023
6.0.23 986,531 10/10/2023
6.0.22 1,840,622 9/12/2023
6.0.21 2,625,722 8/8/2023
6.0.20 2,483,630 7/11/2023
6.0.19 1,635,150 6/22/2023
6.0.18 828,056 6/13/2023
6.0.16 6,762,692 4/11/2023
6.0.15 4,093,210 3/14/2023
6.0.14 4,438,657 2/14/2023
6.0.13 7,040,931 1/10/2023
6.0.12 10,456,978 12/13/2022
6.0.11 7,470,164 11/7/2022
6.0.10 11,515,570 10/11/2022
6.0.9 8,740,871 9/13/2022
6.0.8 10,929,948 8/9/2022
6.0.7 8,831,191 7/12/2022
6.0.6 7,151,217 6/14/2022
6.0.5 10,155,969 5/10/2022
6.0.4 8,011,857 4/11/2022
6.0.3 9,412,962 3/8/2022
6.0.2 7,344,233 2/8/2022
6.0.1 12,574,947 12/14/2021
6.0.0 12,532,898 11/8/2021
6.0.0-rc.2.21480.10 74,872 10/12/2021
6.0.0-rc.1.21452.15 59,495 9/14/2021
6.0.0-preview.7.21378.6 65,689 8/10/2021
6.0.0-preview.6.21355.2 19,071 7/14/2021
6.0.0-preview.5.21301.17 11,543 6/15/2021
6.0.0-preview.4.21253.5 9,819 5/24/2021
6.0.0-preview.3.21201.13 13,527 4/8/2021
6.0.0-preview.2.21154.6 3,898 3/11/2021 6.0.0-preview.2.21154.6 is deprecated because it is no longer maintained.
6.0.0-preview.1.21103.6 6,354 2/12/2021 6.0.0-preview.1.21103.6 is deprecated because it is no longer maintained.
5.0.17 2,619,896 5/10/2022 5.0.17 is deprecated because it is no longer maintained.
5.0.16 642,912 4/11/2022 5.0.16 is deprecated because it is no longer maintained.
5.0.15 1,003,779 3/8/2022 5.0.15 is deprecated because it is no longer maintained.
5.0.14 941,235 2/8/2022 5.0.14 is deprecated because it is no longer maintained.
5.0.13 2,503,339 12/14/2021 5.0.13 is deprecated because it is no longer maintained.
5.0.12 20,221,721 11/7/2021 5.0.12 is deprecated because it is no longer maintained.
5.0.11 3,849,935 10/12/2021 5.0.11 is deprecated because it is no longer maintained.
5.0.10 3,884,415 9/14/2021 5.0.10 is deprecated because it is no longer maintained.
5.0.9 7,356,428 8/10/2021 5.0.9 is deprecated because it is no longer maintained.
5.0.8 2,869,418 7/13/2021 5.0.8 is deprecated because it is no longer maintained; 5.0.8 has at least one vulnerability with moderate severity.
5.0.7 4,121,862 6/8/2021 5.0.7 is deprecated because it is no longer maintained; 5.0.7 has at least one vulnerability with moderate severity.
5.0.6 2,933,605 5/11/2021 5.0.6 is deprecated because it is no longer maintained; 5.0.6 has at least one vulnerability with moderate severity.
5.0.5 4,146,427 4/6/2021 5.0.5 is deprecated because it is no longer maintained; 5.0.5 has at least one vulnerability with moderate severity.
5.0.4 2,952,782 3/9/2021 5.0.4 is deprecated because it is no longer maintained; 5.0.4 has at least one vulnerability with moderate severity.
5.0.3 3,128,505 2/9/2021 5.0.3 is deprecated because it is no longer maintained; 5.0.3 has at least one vulnerability with moderate severity.
5.0.2 2,800,073 1/12/2021 5.0.2 is deprecated because it is no longer maintained; 5.0.2 has at least one vulnerability with moderate severity.
5.0.1 3,155,867 12/8/2020 5.0.1 is deprecated because it is no longer maintained; 5.0.1 has at least one vulnerability with moderate severity.
5.0.0 10,814,722 11/9/2020 5.0.0 is deprecated because it is no longer maintained; 5.0.0 has at least one vulnerability with moderate severity.
5.0.0-rc.2.20475.17 106,186 10/13/2020 5.0.0-rc.2.20475.17 is deprecated because it is no longer maintained.
5.0.0-rc.1.20451.17 272,531 9/14/2020 5.0.0-rc.1.20451.17 is deprecated because it is no longer maintained.
5.0.0-preview.8.20414.8 1,331,569 8/25/2020 5.0.0-preview.8.20414.8 is deprecated because it is no longer maintained.
5.0.0-preview.7.20365.19 16,608 7/21/2020 5.0.0-preview.7.20365.19 is deprecated because it is no longer maintained.
5.0.0-preview.6.20312.15 20,518 6/25/2020 5.0.0-preview.6.20312.15 is deprecated because it is no longer maintained.
5.0.0-preview.5.20279.2 3,443 6/10/2020 5.0.0-preview.5.20279.2 is deprecated because it is no longer maintained.
5.0.0-preview.4.20257.10 4,292 5/18/2020 5.0.0-preview.4.20257.10 is deprecated because it is no longer maintained.
5.0.0-preview.3.20215.14 4,397 4/23/2020 5.0.0-preview.3.20215.14 is deprecated because it is no longer maintained.
5.0.0-preview.2.20167.3 3,465 4/2/2020 5.0.0-preview.2.20167.3 is deprecated because it is no longer maintained.
5.0.0-preview.1.20124.5 5,486 3/16/2020 5.0.0-preview.1.20124.5 is deprecated because it is no longer maintained.
3.1.32 2,048,907 12/13/2022
3.1.31 258,989 11/8/2022
3.1.30 205,373 10/11/2022
3.1.29 247,780 9/13/2022
3.1.28 2,022,967 8/9/2022
3.1.27 353,842 7/12/2022
3.1.26 341,555 6/14/2022
3.1.25 631,602 5/10/2022
3.1.24 454,464 4/11/2022
3.1.23 1,924,120 3/8/2022
3.1.22 3,041,999 12/14/2021
3.1.21 2,196,825 11/7/2021
3.1.20 978,378 10/11/2021
3.1.19 1,218,290 9/14/2021
3.1.18 7,749,106 8/10/2021
3.1.17 1,088,523 7/13/2021 3.1.17 has at least one vulnerability with moderate severity.
3.1.16 2,146,970 6/8/2021 3.1.16 has at least one vulnerability with moderate severity.
3.1.15 1,585,873 5/11/2021 3.1.15 has at least one vulnerability with moderate severity.
3.1.14 2,026,410 4/6/2021 3.1.14 has at least one vulnerability with moderate severity.
3.1.13 2,336,009 3/9/2021 3.1.13 has at least one vulnerability with moderate severity.
3.1.12 2,112,668 2/9/2021 3.1.12 has at least one vulnerability with moderate severity.
3.1.11 3,454,251 1/12/2021 3.1.11 has at least one vulnerability with moderate severity.
3.1.10 5,612,766 11/9/2020 3.1.10 has at least one vulnerability with moderate severity.
3.1.9 6,144,521 10/13/2020 3.1.9 has at least one vulnerability with moderate severity.
3.1.8 10,506,678 9/8/2020 3.1.8 has at least one vulnerability with moderate severity.
3.1.7 4,687,588 8/11/2020 3.1.7 has at least one vulnerability with moderate severity.
3.1.6 5,505,570 7/14/2020 3.1.6 has at least one vulnerability with moderate severity.
3.1.5 7,857,827 6/9/2020 3.1.5 has at least one vulnerability with moderate severity.
3.1.4 7,169,073 5/12/2020 3.1.4 has at least one vulnerability with moderate severity.
3.1.3 9,465,064 3/24/2020 3.1.3 has at least one vulnerability with moderate severity.
3.1.2 7,085,751 2/18/2020 3.1.2 has at least one vulnerability with moderate severity.
3.1.1 9,432,504 1/14/2020 3.1.1 has at least one vulnerability with moderate severity.
3.1.0 7,217,414 12/3/2019 3.1.0 has at least one vulnerability with moderate severity.
3.1.0-preview3.19555.2 13,590 11/13/2019 3.1.0-preview3.19555.2 is deprecated because it is no longer maintained; 3.1.0-preview3.19555.2 has at least one vulnerability with moderate severity.
3.1.0-preview2.19528.8 3,371 11/1/2019 3.1.0-preview2.19528.8 is deprecated because it is no longer maintained; 3.1.0-preview2.19528.8 has at least one vulnerability with moderate severity.
3.1.0-preview1.19508.20 7,346 10/15/2019 3.1.0-preview1.19508.20 is deprecated because it is no longer maintained; 3.1.0-preview1.19508.20 has at least one vulnerability with moderate severity.
3.0.3 671,824 2/18/2020 3.0.3 is deprecated because it is no longer maintained; 3.0.3 has at least one vulnerability with moderate severity.
3.0.2 286,012 1/14/2020 3.0.2 is deprecated because it is no longer maintained; 3.0.2 has at least one vulnerability with moderate severity.
3.0.0 38,971,707 9/23/2019 3.0.0 is deprecated because it is no longer maintained; 3.0.0 has at least one vulnerability with moderate severity.
3.0.0-rc1.19457.4 24,976 9/16/2019 3.0.0-rc1.19457.4 is deprecated because it is no longer maintained.
3.0.0-preview9.19424.4 147,320 9/4/2019 3.0.0-preview9.19424.4 is deprecated because it is no longer maintained.
3.0.0-preview8.19405.7 27,860 8/13/2019 3.0.0-preview8.19405.7 is deprecated because it is no longer maintained.
3.0.0-preview7.19365.7 40,105 7/23/2019 3.0.0-preview7.19365.7 is deprecated because it is no longer maintained.
3.0.0-preview6.19307.2 36,496 6/12/2019 3.0.0-preview6.19307.2 is deprecated because it is no longer maintained.
3.0.0-preview5-19227-01 24,013 5/6/2019 3.0.0-preview5-19227-01 is deprecated because it is no longer maintained.
3.0.0-preview4-19216-03 6,987 4/18/2019 3.0.0-preview4-19216-03 is deprecated because it is no longer maintained.
3.0.0-preview3-19153-02 7,732 3/6/2019 3.0.0-preview3-19153-02 is deprecated because it is no longer maintained.
3.0.0-preview-19075-0444 12,283 1/29/2019 3.0.0-preview-19075-0444 is deprecated because it is no longer maintained.
2.2.0 28,292,252 12/3/2018 2.2.0 is deprecated because it is no longer maintained.
2.2.0-preview3-35497 71,417 10/17/2018 2.2.0-preview3-35497 is deprecated because it is no longer maintained.
2.2.0-preview2-35157 36,179 9/12/2018 2.2.0-preview2-35157 is deprecated because it is no longer maintained.
2.2.0-preview1-35029 8,898 8/22/2018 2.2.0-preview1-35029 is deprecated because it is no longer maintained.
2.1.30 961,889 8/19/2021
2.1.2 17,459,321 8/21/2018 2.1.2 has at least one vulnerability with moderate severity.
2.1.1 11,644,709 6/18/2018 2.1.1 has at least one vulnerability with moderate severity.
2.1.0 14,957,332 5/29/2018 2.1.0 has at least one vulnerability with moderate severity.
2.1.0-rc1-final 40,926 5/6/2018 2.1.0-rc1-final is deprecated because it is no longer maintained.
2.1.0-preview2-final 38,728 4/10/2018 2.1.0-preview2-final is deprecated because it is no longer maintained.
2.1.0-preview1-final 53,754 2/26/2018 2.1.0-preview1-final is deprecated because it is no longer maintained.
2.0.4 4,536,026 5/7/2018 2.0.4 is deprecated because it is no longer maintained.
2.0.3 4,162,932 3/13/2018 2.0.3 is deprecated because it is no longer maintained.
2.0.1 7,440,187 11/14/2017 2.0.1 is deprecated because it is no longer maintained.
2.0.0 12,102,373 8/11/2017 2.0.0 is deprecated because it is no longer maintained.
2.0.0-preview2-final 55,790 6/27/2017 2.0.0-preview2-final is deprecated because it is no longer maintained.
2.0.0-preview1-final 17,800 5/10/2017 2.0.0-preview1-final is deprecated because it is no longer maintained.
1.1.3 471,140 9/20/2017 1.1.3 is deprecated because it is no longer maintained.
1.1.2 1,250,164 5/9/2017 1.1.2 is deprecated because it is no longer maintained.
1.1.1 472,600 3/6/2017 1.1.1 is deprecated because it is no longer maintained.
1.1.0 396,423 11/16/2016 1.1.0 is deprecated because it is no longer maintained.
1.1.0-preview1-final 6,524 10/24/2016 1.1.0-preview1-final is deprecated because it is no longer maintained.
1.0.5 12,501 11/14/2017 1.0.5 is deprecated because it is no longer maintained.
1.0.4 6,510 9/20/2017 1.0.4 is deprecated because it is no longer maintained.
1.0.3 18,161 5/9/2017 1.0.3 is deprecated because it is no longer maintained.
1.0.2 115,765 3/6/2017 1.0.2 is deprecated because it is no longer maintained.
1.0.1 21,771 12/12/2016 1.0.1 is deprecated because it is no longer maintained.
1.0.0 717,696 6/27/2016 1.0.0 is deprecated because it is no longer maintained.
1.0.0-rc2-final 19,523 5/16/2016 1.0.0-rc2-final is deprecated because it is no longer maintained.