Create a new web api project
Run these commands in a sequence to create a new project.
dotnet new sln -o JwtDotnet9
cd JwtDotnet9
dotnet sln add JwtDotnet9/JwtDotnet9.csproj
Open the project in vs code.
code .
=> Source Code
=> Securing The .NET 9 App: Signup, Login, JWT, Refresh Tokens, and Role Based Access with PostgreSQL
Install the required nuget packages
dotnet add package Microsoft.AspNetCore.Authentication.JwtBearer
Jwt configuration in appsettings
Open appsettings.json
and add these lines