I'm trying to create Asp.NET Core API and add Jwt authentication. In all examples, that I've found so far is used SymmetricSecurityKey. I've added Aspnetcore.Authentication.JwtBearer package but there is doesn't exist SymmetricSecurityKey. What package I've to add to resolve dependency to this class?
Thank you in advance.
Determines whether the specified object is equal to the current object. When overridden in a derived class, generates a derived key using the specified cryptographic algorithm and parameters for the current key.
JSON Web Tokens (commonly known as JWT) is an open standard to pass data between client and server, and enables you to transmit data back and forth between the server and the consumers in a secure manner. This article talks about how you can take advantage of JWTs to protect APIs.
Additional resources. Authentication is the process of determining a user's identity. Authorization is the process of determining whether a user has access to a resource. In ASP.NET Core, authentication is handled by the authentication service, IAuthenticationService, which is used by authentication middleware.
For .NET Core 3.0:
A lot of things have been broken off into individual packages that have to be added to your project. Therefore:
$ dotnet add package Microsoft.AspNetCore.Authentication.JwtBearer --version 3.0.0
Which adds the following line to the .csproj:
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.0.0" />
At that point, as other answers have stated, you can import:
using System.IdentityModel.Tokens.Jwt;
Nuget Package Link
For me it required using Microsoft.IdentityModel.Tokens;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With