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.

By

Updated

Cheat sheet: Requiring a Signed-In User
Category
FastAPI
Level
Journeyman
Tags
401 Unauthorized, Authentication, Authorization, Bearer Token, fastapi, rest-api, Security Dependencies