FastAPI JWT Token Auth • Full access + one-time refresh token

FastAPI JWT Token Auth • Full access + one-time refresh token

HomeAmo ProceduresFastAPI JWT Token Auth • Full access + one-time refresh token
FastAPI JWT Token Auth • Full access + one-time refresh token
ChannelPublish DateThumbnail & View CountDownload Video
Channel AvatarPublish Date not found Thumbnail
0 Views
In this video we will learn step by step how to implement FastAPI JWT token authentication with a MySQL database using the Tortoise ORM library.

You have extensive knowledge and implement FastAPI dependency injection methods and use JWT web access tokens to authenticate users.

We will create a JWT access token and a JWT refresh token, but there is a more secure way to implement this JWT with refresh token.

JWT Refresh Token: This is a unique token used to obtain additional access tokens. This allows you to have short-lived access tokens without having to re-acquire credentials every time a token expires.

This refresh JWT token is stored in the MySQL user table in my case, but can also be stored in in-memory databases such as the Redis database for enhanced security mechanisms.

Since access tokens are not valid for a long period of time for security reasons, a refresh token helps re-authenticate a user without credentials.

This JWT refresh token is never exposed to the client-side JavaScript. Even if our access token is compromised, it will expire in no time. Therefore, we send two tokens instead of one, an access token and a refresh token.

‍ Hello, I'm Amo Procedures ‍
Hello! I am a software developer. I like to share my knowledge and help others discover the exciting world of programming.

For more tutorials, tips and technical magic tricks, don’t forget to click the subscribe button and ring the bell to receive notifications.

Support the channel
If you found this tutorial helpful, please give it a thumbs up, comment and share it with your network

time stamp

00:00:00 – Introduction
00:00:55 – FastAPI JWT authentication
00:03:00 – Setting up the environment
00:05:19 – First DB migration
00:06:55 – Add user model
00:09:11 – Add user schema
00:11:25 – Initialize API endpoints
00:17:57 – User registration endpoint
00:30:09 – User login and JWT access token
00:40:53 – Refresh endpoint and JWT refresh token
00:45:43 – Accessing protected endpoint with JWT access token

️ Best Fast Python 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 with 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

Please take the opportunity to connect with your friends and family and share this video with them if you find it useful.