# Requiring a Signed-In User

A get_current_user dependency reads the token from the Authorization header with OAuth2PasswordBearer, decodes it with PyJWT and loads the user from the database, so a route that asks for it serves only signed-in users and answers everyone else 401 with a WWW-Authenticate header.

![Cheat sheet: Requiring a Signed-In User](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/ef77142d930147a2904d505da7db5988.webp)

- Category: FastAPI
- Level: Journeyman
- Tags: 401 Unauthorized, Authentication, Authorization, Bearer Token, fastapi, rest-api, Security Dependencies
- Author: Gregor Dzierzon
- Updated: November 23, 2026

Source: https://www.ask-codey.com/cheat-sheets/fastapi-auth-current-user-dependency-cheat-sheet
