In this tutorial we’ll create a .NET 6 Web API (Minimal API) that will enforce JWT Authentication and Authorization. Furthermore, we’ll add Swagger support and configure Bearer Authentication for it, so that all of our endpoints can be testable from Swagger UI using a bearer token.
By the end of this tutorial, you will know:
How to create a Minimal API project
Create and use Data Transfer Objects
Create Services that expose data
Understand the basics Minimal API in .NET 6
Setup a CRUD .NET 6 Web API (Minimal API) that will expose services methods
Configure the API Endpoints for Authentication and Authorization with JWT Bearer
Setup Swagger support and configure bearer authentication with Swagger
Understand the basics of Swagger Documentation in .NET 6
For this tutorial there are two pre-requisites .NET 6 and Visual Studio 2022. Here is a video showing where to download these from: • ASP.NET Core Web API Authentication a...
Source code: https://github.com/iulianoana/Minimal...
👉Join our monthly email club: https://signup.codewithjulian.com
🎉Check Out Further Resources: https://codewithjulian.com
👍If you enjoyed this tutorial, please like this video consider subscribing for more content like this!
😎Subscribe for endless .NET Tutorials: / codewithjulian
0:00 - Intro
0:21 - Create Minimal API Project
1:02 - Add Data Transfer Objects
2:47 - Add Data Repositories
4:59 - Creating Services
11:09 - Install JWT Dependencies
12:17 - Configure Minimal API Endpoints
20:41 - Add Swagger Support
23:30 - Add JWT Authentication
29:03 - Generate JWT on Login
35:05 - Configure Endpoints for Authentication
38:27 - Configure Bearer Authentication in Swagger
43:43 - Swagger Documentation
Useful Links:
Enterprise CRUD API Controller: • Create a CRUD Blazor Webassembly API ...
Basics of JWT: • What is Json Web Token? JWT Token Exp...
Dependencies:
Microsoft.AspNetCore.Authentication.JwtBearer --version 6.0.0
Microsoft.IdentityModel.Tokens --version 6.14.1
System.IdentityModel.Tokens.Jwt --version 6.14.1
Swashbuckle.AspNetCore --version 6.2.3
Credits:
Sound effects obtained from https://www.zapsplat.com
Icons designed by http://www.freepik.com and https://www.flaticon.com/
Images from the artists on https://unsplash.com/
Watch video .NET 6 Web API Authentication | Minimal API & Swagger (CRUD) online without registration, duration hours minute second in high quality. This video was added by user Code with Julian 01 January 1970, don't forget to share it with your friends and acquaintances, it has been viewed on our site 78,905 once and liked it 1.8 thousand people.