Microsoft.AspNetCore.Authentication.JwtBearer 9.0.2

Prefix Reserved
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Microsoft.AspNetCore.Authentication.JwtBearer --version 9.0.2                
NuGet\Install-Package Microsoft.AspNetCore.Authentication.JwtBearer -Version 9.0.2                
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.2" />                
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.2                
#r "nuget: Microsoft.AspNetCore.Authentication.JwtBearer, 9.0.2"                
#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.2

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

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.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2.8K)

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 (390)

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, now community supported: https://github.com/NimblePros/eShopOnWeb
Version Downloads Last updated
10.0.0-preview.1.25120.3 1,712 7 days ago
9.0.2 569,911 21 days ago
9.0.1 1,184,488 2 months ago
9.0.0 3,898,861 4 months ago
9.0.0-rc.2.24474.3 159,155 5 months ago
9.0.0-rc.1.24452.1 75,283 6 months ago
9.0.0-preview.7.24406.2 9,081 7 months ago
9.0.0-preview.6.24328.4 46,073 8 months ago
9.0.0-preview.5.24306.11 5,899 9 months ago
9.0.0-preview.4.24267.6 11,699 9 months ago
9.0.0-preview.3.24172.13 79,963 4/11/2024
9.0.0-preview.2.24128.4 26,029 3/12/2024
9.0.0-preview.1.24081.5 27,559 2/13/2024
8.0.13 540,458 21 days ago
8.0.12 1,490,390 2 months ago
8.0.11 5,640,088 4 months ago
8.0.10 8,841,418 5 months ago
8.0.8 11,281,083 7 months ago
8.0.7 8,146,008 8 months ago
8.0.6 9,683,664 9 months ago
8.0.5 3,390,321 10 months ago
8.0.4 8,638,698 4/9/2024
8.0.3 6,012,995 3/12/2024
8.0.2 6,972,865 2/13/2024
8.0.1 8,285,187 1/9/2024
8.0.0 28,568,929 11/14/2023
8.0.0-rc.2.23480.2 482,267 10/10/2023
8.0.0-rc.1.23421.29 101,903 9/12/2023
8.0.0-preview.7.23375.9 237,966 8/8/2023
8.0.0-preview.6.23329.11 81,662 7/11/2023
8.0.0-preview.5.23302.2 11,838 6/13/2023
8.0.0-preview.4.23260.4 11,522 5/16/2023
8.0.0-preview.3.23177.8 18,906 4/11/2023
8.0.0-preview.2.23153.2 8,749 3/14/2023
8.0.0-preview.1.23112.2 60,282 2/21/2023
7.0.20 1,186,780 9 months ago
7.0.19 130,528 10 months ago
7.0.18 403,808 4/9/2024
7.0.17 420,220 3/12/2024
7.0.16 652,572 2/13/2024
7.0.15 1,149,780 1/9/2024
7.0.14 2,258,989 11/14/2023
7.0.13 2,557,232 10/24/2023
7.0.12 1,983,202 10/10/2023
7.0.11 2,826,142 9/12/2023
7.0.10 3,898,760 8/8/2023
7.0.9 2,826,816 7/11/2023
7.0.8 2,339,778 6/22/2023
7.0.7 1,247,344 6/13/2023
7.0.5 7,307,264 4/11/2023
7.0.4 3,576,315 3/14/2023
7.0.3 3,463,689 2/14/2023
7.0.2 4,405,302 1/10/2023
7.0.1 9,253,572 12/13/2022
7.0.0 5,386,121 11/7/2022
7.0.0-rc.2.22476.2 85,854 10/11/2022
7.0.0-rc.1.22427.2 24,509 9/14/2022
7.0.0-preview.7.22376.6 24,494 8/9/2022
7.0.0-preview.6.22330.3 264,750 7/12/2022
7.0.0-preview.5.22303.8 6,267 6/14/2022
7.0.0-preview.4.22251.1 10,451 5/10/2022
7.0.0-preview.3.22178.4 4,449 4/13/2022
7.0.0-preview.2.22153.2 3,957 3/14/2022
7.0.0-preview.1.22109.13 3,415 2/17/2022
6.0.36 512,474 4 months ago
6.0.35 414,082 5 months ago
6.0.33 1,173,406 7 months ago
6.0.32 994,661 8 months ago
6.0.31 939,934 9 months ago
6.0.30 456,700 10 months ago
6.0.29 1,469,740 4/9/2024
6.0.28 1,194,354 3/12/2024
6.0.27 1,520,786 2/13/2024
6.0.26 2,838,409 1/9/2024
6.0.25 3,590,012 11/14/2023
6.0.24 2,139,215 10/24/2023
6.0.23 1,073,672 10/10/2023
6.0.22 2,020,513 9/12/2023
6.0.21 2,825,712 8/8/2023
6.0.20 2,678,936 7/11/2023
6.0.19 1,741,231 6/22/2023
6.0.18 874,622 6/13/2023
6.0.16 7,263,205 4/11/2023
6.0.15 4,495,232 3/14/2023
6.0.14 4,686,121 2/14/2023
6.0.13 7,516,502 1/10/2023
6.0.12 11,273,167 12/13/2022
6.0.11 7,938,942 11/7/2022
6.0.10 12,043,168 10/11/2022
6.0.9 9,133,911 9/13/2022
6.0.8 11,388,223 8/9/2022
6.0.7 9,232,228 7/12/2022
6.0.6 7,422,157 6/14/2022
6.0.5 10,529,115 5/10/2022
6.0.4 8,330,367 4/11/2022
6.0.3 9,691,357 3/8/2022
6.0.2 7,556,325 2/8/2022
6.0.1 13,052,392 12/14/2021
6.0.0 13,284,019 11/8/2021
6.0.0-rc.2.21480.10 75,967 10/12/2021
6.0.0-rc.1.21452.15 60,367 9/14/2021
6.0.0-preview.7.21378.6 66,645 8/10/2021
6.0.0-preview.6.21355.2 19,441 7/14/2021
6.0.0-preview.5.21301.17 11,735 6/15/2021
6.0.0-preview.4.21253.5 9,934 5/24/2021
6.0.0-preview.3.21201.13 13,759 4/8/2021
6.0.0-preview.2.21154.6 3,988 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,485 2/12/2021 6.0.0-preview.1.21103.6 is deprecated because it is no longer maintained.
5.0.17 2,799,860 5/10/2022 5.0.17 is deprecated because it is no longer maintained.
5.0.16 656,613 4/11/2022 5.0.16 is deprecated because it is no longer maintained.
5.0.15 1,064,022 3/8/2022 5.0.15 is deprecated because it is no longer maintained.
5.0.14 967,064 2/8/2022 5.0.14 is deprecated because it is no longer maintained.
5.0.13 2,562,202 12/14/2021 5.0.13 is deprecated because it is no longer maintained.
5.0.12 21,032,709 11/7/2021 5.0.12 is deprecated because it is no longer maintained.
5.0.11 3,920,066 10/12/2021 5.0.11 is deprecated because it is no longer maintained.
5.0.10 3,957,366 9/14/2021 5.0.10 is deprecated because it is no longer maintained.
5.0.9 7,508,333 8/10/2021 5.0.9 is deprecated because it is no longer maintained.
5.0.8 2,906,123 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,177,129 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,985,269 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,210,593 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,988,486 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,159,224 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,878,915 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,202,881 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 11,262,958 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 108,293 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 303,323 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 3,331,688 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,736 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,945 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,528 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,379 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,487 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,556 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,581 3/16/2020 5.0.0-preview.1.20124.5 is deprecated because it is no longer maintained.
3.1.32 2,384,381 12/13/2022
3.1.31 276,577 11/8/2022
3.1.30 213,834 10/11/2022
3.1.29 262,029 9/13/2022
3.1.28 2,202,595 8/9/2022
3.1.27 368,077 7/12/2022
3.1.26 353,024 6/14/2022
3.1.25 654,610 5/10/2022
3.1.24 472,822 4/11/2022
3.1.23 2,063,676 3/8/2022
3.1.22 3,167,755 12/14/2021
3.1.21 2,237,500 11/7/2021
3.1.20 1,004,134 10/11/2021
3.1.19 1,240,214 9/14/2021
3.1.18 8,123,253 8/10/2021
3.1.17 1,106,776 7/13/2021 3.1.17 has at least one vulnerability with moderate severity.
3.1.16 2,186,181 6/8/2021 3.1.16 has at least one vulnerability with moderate severity.
3.1.15 1,610,213 5/11/2021 3.1.15 has at least one vulnerability with moderate severity.
3.1.14 2,064,634 4/6/2021 3.1.14 has at least one vulnerability with moderate severity.
3.1.13 2,366,146 3/9/2021 3.1.13 has at least one vulnerability with moderate severity.
3.1.12 2,143,517 2/9/2021 3.1.12 has at least one vulnerability with moderate severity.
3.1.11 3,488,937 1/12/2021 3.1.11 has at least one vulnerability with moderate severity.
3.1.10 5,659,019 11/9/2020 3.1.10 has at least one vulnerability with moderate severity.
3.1.9 6,237,846 10/13/2020 3.1.9 has at least one vulnerability with moderate severity.
3.1.8 10,624,582 9/8/2020 3.1.8 has at least one vulnerability with moderate severity.
3.1.7 4,735,237 8/11/2020 3.1.7 has at least one vulnerability with moderate severity.
3.1.6 5,609,745 7/14/2020 3.1.6 has at least one vulnerability with moderate severity.
3.1.5 7,936,826 6/9/2020 3.1.5 has at least one vulnerability with moderate severity.
3.1.4 7,236,244 5/12/2020 3.1.4 has at least one vulnerability with moderate severity.
3.1.3 9,638,612 3/24/2020 3.1.3 has at least one vulnerability with moderate severity.
3.1.2 7,168,073 2/18/2020 3.1.2 has at least one vulnerability with moderate severity.
3.1.1 9,569,925 1/14/2020 3.1.1 has at least one vulnerability with moderate severity.
3.1.0 7,324,035 12/3/2019 3.1.0 has at least one vulnerability with moderate severity.
3.1.0-preview3.19555.2 13,768 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,457 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,451 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 681,442 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 289,813 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 40,711,636 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 25,132 9/16/2019 3.0.0-rc1.19457.4 is deprecated because it is no longer maintained.
3.0.0-preview9.19424.4 152,589 9/4/2019 3.0.0-preview9.19424.4 is deprecated because it is no longer maintained.
3.0.0-preview8.19405.7 27,956 8/13/2019 3.0.0-preview8.19405.7 is deprecated because it is no longer maintained.
3.0.0-preview7.19365.7 40,243 7/23/2019 3.0.0-preview7.19365.7 is deprecated because it is no longer maintained.
3.0.0-preview6.19307.2 36,800 6/12/2019 3.0.0-preview6.19307.2 is deprecated because it is no longer maintained.
3.0.0-preview5-19227-01 24,228 5/6/2019 3.0.0-preview5-19227-01 is deprecated because it is no longer maintained.
3.0.0-preview4-19216-03 7,086 4/18/2019 3.0.0-preview4-19216-03 is deprecated because it is no longer maintained.
3.0.0-preview3-19153-02 7,817 3/6/2019 3.0.0-preview3-19153-02 is deprecated because it is no longer maintained.
3.0.0-preview-19075-0444 12,433 1/29/2019 3.0.0-preview-19075-0444 is deprecated because it is no longer maintained.
2.3.0 4,282 2 months ago
2.2.0 29,217,156 12/3/2018 2.2.0 is deprecated because it is no longer maintained.
2.2.0-preview3-35497 71,677 10/17/2018 2.2.0-preview3-35497 is deprecated because it is no longer maintained.
2.2.0-preview2-35157 37,598 9/12/2018 2.2.0-preview2-35157 is deprecated because it is no longer maintained.
2.2.0-preview1-35029 9,046 8/22/2018 2.2.0-preview1-35029 is deprecated because it is no longer maintained.
2.1.30 1,121,033 8/19/2021
2.1.2 17,571,007 8/21/2018 2.1.2 has at least one vulnerability with moderate severity.
2.1.1 12,269,736 6/18/2018 2.1.1 has at least one vulnerability with moderate severity.
2.1.0 15,199,126 5/29/2018 2.1.0 has at least one vulnerability with moderate severity.
2.1.0-rc1-final 41,146 5/6/2018 2.1.0-rc1-final is deprecated because it is no longer maintained.
2.1.0-preview2-final 38,995 4/10/2018 2.1.0-preview2-final is deprecated because it is no longer maintained.
2.1.0-preview1-final 54,031 2/26/2018 2.1.0-preview1-final is deprecated because it is no longer maintained.
2.0.4 4,618,796 5/7/2018 2.0.4 is deprecated because it is no longer maintained.
2.0.3 4,212,443 3/13/2018 2.0.3 is deprecated because it is no longer maintained.
2.0.1 7,554,396 11/14/2017 2.0.1 is deprecated because it is no longer maintained.
2.0.0 12,232,758 8/11/2017 2.0.0 is deprecated because it is no longer maintained.
2.0.0-preview2-final 56,279 6/27/2017 2.0.0-preview2-final is deprecated because it is no longer maintained.
2.0.0-preview1-final 18,104 5/10/2017 2.0.0-preview1-final is deprecated because it is no longer maintained.
1.1.3 482,626 9/20/2017 1.1.3 is deprecated because it is no longer maintained.
1.1.2 1,261,526 5/9/2017 1.1.2 is deprecated because it is no longer maintained.
1.1.1 477,770 3/6/2017 1.1.1 is deprecated because it is no longer maintained.
1.1.0 399,018 11/16/2016 1.1.0 is deprecated because it is no longer maintained.
1.1.0-preview1-final 6,689 10/24/2016 1.1.0-preview1-final is deprecated because it is no longer maintained.
1.0.5 12,779 11/14/2017 1.0.5 is deprecated because it is no longer maintained.
1.0.4 6,783 9/20/2017 1.0.4 is deprecated because it is no longer maintained.
1.0.3 18,771 5/9/2017 1.0.3 is deprecated because it is no longer maintained.
1.0.2 116,726 3/6/2017 1.0.2 is deprecated because it is no longer maintained.
1.0.1 21,954 12/12/2016 1.0.1 is deprecated because it is no longer maintained.
1.0.0 766,182 6/27/2016 1.0.0 is deprecated because it is no longer maintained.
1.0.0-rc2-final 19,682 5/16/2016 1.0.0-rc2-final is deprecated because it is no longer maintained.