Skip to content
masterclass Buddy

FastAPI · Class

OAuth2PasswordBearer

OAuth2PasswordBearer reads a Bearer token from the Authorization header. Use it as a FastAPI dependency to protect endpoints and document the OAuth2 scheme in OpenAPI.

Last updated

Syntax

OAuth2PasswordBearer(tokenUrl, scheme_name=None, scopes=None, description=None, auto_error=True, refreshUrl=None)

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • OAuth2PasswordRequestForm
  • OAuth2PasswordRequestFormStrict
  • OAuth2
  • SecurityBase
  • Depends
  • SecurityScopes

Source: Security Tools - FastAPI. Checked 2026-11-03.