Bird
0
0

To restrict access to an API endpoint only to clients with valid Bearer tokens, which of the following is the best practice?

hard📝 Application Q8 of 15
Rest API - Authentication and Authorization
To restrict access to an API endpoint only to clients with valid Bearer tokens, which of the following is the best practice?
AValidate the Bearer token on the server side before processing the request
BSend the token as a URL query parameter for easier access
CStore the token in client-side cookies without HttpOnly flag
DAllow requests without tokens but log them for review
Step-by-Step Solution
Solution:
  1. Step 1: Understand API security best practices

    Bearer tokens must be validated on the server to ensure only authorized clients access protected endpoints.
  2. Step 2: Evaluate options

    Validate the Bearer token on the server side before processing the request correctly states server-side validation. Send the token as a URL query parameter for easier access is insecure as tokens in URLs can be logged or leaked. Store the token in client-side cookies without HttpOnly flag risks token theft by not using HttpOnly cookies. Allow requests without tokens but log them for review allows unauthorized access.
  3. Final Answer:

    Validate the Bearer token on the server side before processing the request -> Option A
  4. Quick Check:

    Always validate tokens server-side to secure endpoints [OK]
Quick Trick: Always validate tokens server-side before granting access [OK]
Common Mistakes:
  • Passing tokens in URL parameters
  • Not validating tokens on server
  • Storing tokens insecurely on client

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes