Bird
0
0

When a client sends a request with an expired JWT token to a Django REST Framework view protected by JWTAuthentication, what HTTP status code is typically returned?

medium📝 component behavior Q5 of 15
Django - DRF Advanced Features
When a client sends a request with an expired JWT token to a Django REST Framework view protected by JWTAuthentication, what HTTP status code is typically returned?
A401 Unauthorized
B403 Forbidden
C400 Bad Request
D500 Internal Server Error
Step-by-Step Solution
Solution:
  1. Step 1: Understand JWT token expiration

    When a JWT token is expired, the authentication fails because the token is no longer valid.
  2. Step 2: Identify the correct HTTP status

    DRF returns 401 Unauthorized to indicate authentication failure due to invalid or expired credentials.
  3. Final Answer:

    401 Unauthorized -> Option A
  4. Quick Check:

    Expired JWT tokens cause authentication failure, resulting in 401. [OK]
Quick Trick: Expired JWT tokens cause 401 Unauthorized response. [OK]
Common Mistakes:
MISTAKES
  • Confusing 403 Forbidden with authentication failure.
  • Assuming expired tokens cause 400 Bad Request.
  • Thinking server errors (500) occur on token expiration.

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Django Quizzes