Typically one creates a RESTful API so that one can have a completely decoupled front and backend. As a result you typically want to have stateless authentication, i.e. you don't have a session stored in a database but instead your authentication is checked on every request.
In this video I show you how you can set up security with JWT (JSON web tokens) to enable said stateless authentication.
GitHub: https://github.com/jvp-design/fastapi-tutorial/tree/27-security_oauth_jwt