Authentication and authorization are key features in almost all web applications. How to do it with Fast API? Actually, there is a complete section of documentation covering security with JWT tokens . But if you try to follow the documentation, you will find them using pydantic models. No database integration and without an actual structure. In this article, I'll cover the basic authentication using JWT tokens with sqlmodel , a modular structure, and register , login , refresh , change-password , and me endpoints. I'll build on the Franky project structure we started in the previous article , please refer to it for a more detailed description of our project structure and used libs. JWT authentication required libraries We will need two libraries, PyJWT for token encryption and decryption, and pwdlib for user password hashing. uv add pyjwt uv add 'pwdlib[argon2]' Enter fullscreen mode Exit fullscreen mode Don't ignore the '' in pwlib . The recommended hashing algorithm is 'Argon2'.…