✅ FastAPI JWT Token Auth • Full Access + One-Time Refresh Token
In this video we're going to learn process by process on how to implement fastapi jwt token authentication with mysql database using tortoise-orm library.
U will have a deep understanding and implement fastapi dependency injection methods and use jwt web access token to authenticate users.
We create a jwt access token and a jwt refresh token. But there is a more secure way to implement this jwt using refresh tokens.
JWT Refresh Tokens: It is a unique token that is used to obtain additional access tokens. This allows you to have short-lived access tokens without having to collect credentials every time one expires.
This refresh jwt token for my case will be stored in mysql users table but can either be strored in memory databases like redis database for advanced security mechanisms.
Since access tokens aren’t valid for an extended period because of security reasons, a refresh token helps to re-authenticate a user without login credentials.
This JWT Refresh token is never exposed to the client-side Javascript, even if our access token gets compromised it’ll be expired in a very short duration. So, we will be sending two tokens instead of one, an access token and a refresh token.
👨💻 Hi, I am Amo Procedures 👨💻
Hey! I’m a software enginner. I love sharing my knowledge and helping others to discover the exciting world of programming.
For more tutorials, tips, and tech magic, don’t forget to hit that subscribe button and ring the bell for notifications.
🙏 Support The Channel 🙏
If you found this tutorial helpful, please give it a thumbs up 👍, comment, and share it with your network 🌍
⌚timestamp⌚
00:00:00 - Intro
00:00:55 - FastAPI JWT Auth
00:03:00 - Setting up Environment
00:05:19 - Intial DB Migration
00:06:55 - Add User Model
00:09:11 - Add User Schema
00:11:25 - Initialize API Endpoints
00:17:57 - User Registeration Endpoint
00:30:09 - User Login and JWT Access Token
00:40:53 - Refresh Endpoint and JWT Refresh Token
00:45:43 - Access Protected Endpoint with JWT Access Token
⬇️ Best Python Fast API Programming
https://www.youtube.com/playlist?list=PLp0LE6wXbOGYU1ZuwjxDI-Sa_DlI0sAPr
⬇️ Source Code
https://github.com/amoprocedures/fastapi-jwt
⬇️ How to Easily Create a Cron Job using Python FastAPI
https://www.youtube.com/watch?v=cjkJVBX6jU8
⬇️ Web Scraping with Python and FastAPI
https://www.youtube.com/watch?v=P5yGzJiGFIQ
⬇️ Implement GOOGLE SIGNIN
https://www.youtube.com/watch?v=5h63AfcVerM