Bird
0
0

How can a REST API combine rate limit error responses with authentication errors effectively?

hard📝 Application Q9 of 15
Rest API - Error Handling
How can a REST API combine rate limit error responses with authentication errors effectively?
AReturn 401 Unauthorized before checking rate limits
BReturn 429 status with Retry-After header only after successful authentication
CReturn 429 status without Retry-After header when authentication fails
DIgnore authentication and always return 429 when rate limit exceeded
Step-by-Step Solution
Solution:
  1. Step 1: Understand order of checks in API

    Authentication must be verified before rate limiting to avoid leaking info or wasting resources.
  2. Step 2: Identify correct response order

    Return 401 Unauthorized if authentication fails, only then apply rate limiting and return 429 if needed.
  3. Final Answer:

    Return 401 Unauthorized before checking rate limits -> Option A
  4. Quick Check:

    Authenticate first, then rate limit [OK]
Quick Trick: Authenticate before applying rate limits [OK]
Common Mistakes:
  • Applying rate limits before authentication
  • Returning 429 without Retry-After header
  • Ignoring authentication errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes