JWT_Service 1.9.0
dotnet add package JWT_Service --version 1.9.0
NuGet\Install-Package JWT_Service -Version 1.9.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="JWT_Service" Version="1.9.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="JWT_Service" Version="1.9.0" />
<PackageReference Include="JWT_Service" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add JWT_Service --version 1.9.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: JWT_Service, 1.9.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.
#:package JWT_Service@1.9.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=JWT_Service&version=1.9.0
#tool nuget:?package=JWT_Service&version=1.9.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
This NuGet package demonstrates the use of JWT bearer tokens, providing user claims and error-handling services that track and store errors in a database for .NET applications. It is designed to simplify development in just 2-3 steps.
Error handling is under reconstruction. Suggested not to use only Error handling .It will be released soon...
Usage
JWT Token Service (This service generates a JWT token containing user claims.)
- Configure in Program.cs:
using JWT_Service.Services.JWT;
builder.Services.AddSingleton<JwtTokenService>();
builder.Services.AddJwtAuthentication(builder.Configuration);
- Configuration in appsettings.json:
"Jwt": {
"Key": "strong key more than 256 bits",
"Issuer": "IssuerName",
"Audience": "AudienceName",
"Subject": "SubjectName"
}
- Usage in Code:
private readonly JwtTokenService _jwtTokenService;
public YourClassName(JwtTokenService jwtTokenService) { _jwtTokenService =
jwtTokenService; }
var token = _jwtTokenService.GenerateToken(Username, Userrole);
Error handling Service (This service tracks errors in methods and stores them in the database.):
- Program.cs
using Microsoft.EntityFrameworkCore;
using JWT_Service.Services.Error_Handling;
builder.Services.AddErrorHandling(builder.Configuration.GetConnectionString("**Your_Connection_Name**"));
- Use case:
public async Task<IActionResult> SomeAction()
{
try
{
// Some logic that might throw an exception
}
catch (Exception ex)
{
var controllerName = ControllerContext.ActionDescriptor.ControllerName;
var actionName = ControllerContext.ActionDescriptor.ActionName;
await _errorLogService.LogErrorAsync(
controllerName,
actionName,
ex.GetType().ToString(),
ex.Message,
ex.StackTrace
);
return StatusCode(StatusCodes.Status500InternalServerError, "An unexpected error occurred.");
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. 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. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Microsoft.AspNetCore.Authentication.JwtBearer (>= 8.0.8)
- Microsoft.Data.SqlClient (>= 5.2.2)
- Microsoft.EntityFrameworkCore (>= 8.0.8)
- Microsoft.EntityFrameworkCore.SqlServer (>= 8.0.8)
- Microsoft.Extensions.Configuration (>= 8.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.