Bird
0
0

Why does OAuth2PasswordBearer require a 'tokenUrl' parameter even if the token is sent in the Authorization header?

hard🧠 Conceptual Q10 of 15
FastAPI - Authentication and Security
Why does OAuth2PasswordBearer require a 'tokenUrl' parameter even if the token is sent in the Authorization header?
AIt validates the token against the URL automatically
BIt fetches the token from the tokenUrl during requests
CIt redirects unauthorized requests to the tokenUrl
DIt is used to generate OpenAPI docs showing where to get tokens
Step-by-Step Solution
Solution:
  1. Step 1: Understand tokenUrl role in OAuth2PasswordBearer

    tokenUrl is used to document the token endpoint in OpenAPI docs, not for runtime validation.
  2. Step 2: Eliminate other options

    It does not validate tokens, redirect, or fetch tokens from tokenUrl automatically.
  3. Final Answer:

    It is used to generate OpenAPI docs showing where to get tokens -> Option D
  4. Quick Check:

    tokenUrl is for docs, not validation [OK]
Quick Trick: tokenUrl is for OpenAPI docs only [OK]
Common Mistakes:
MISTAKES
  • Thinking tokenUrl validates tokens
  • Assuming tokenUrl redirects requests
  • Believing tokenUrl fetches tokens

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More FastAPI Quizzes