r/FastAPI • u/Competitive-Tough442 • Feb 07 '25
Question Inject authenticated user into request
Hello, I'm new to python and Fast API in general, I'm trying to get the authenticated user into the request so my handler method can use it. Is there a way i can do this without passing the request down from the route function to the handler. My router functions and service handlers are in different files
9
Upvotes
View all comments
Show parent comment
1
u/Competitive-Tough442 Feb 09 '25
yeah i have that, by using the dependencies (lemme know if it's wrong). I then inject the user object into the request. My name issue now is how to retrieve that request object in the service handler
this is my file structure and business logic is done in the handler.py, i don't want to manually pass the request from the path operation to the handler method
/applications
router.py
handler.py