Bird
0
0

You need to design a REST API that supports user authentication without violating statelessness. Which approach best fits this requirement?

hard📝 Application Q8 of 15
Rest API - REST API Fundamentals
You need to design a REST API that supports user authentication without violating statelessness. Which approach best fits this requirement?
AStore user sessions on the server and use session IDs in cookies
BKeep user login state in server memory between requests
CUse JSON Web Tokens (JWT) sent with each request for authentication
DRequire clients to log in once and rely on server session
Step-by-Step Solution
Solution:
  1. Step 1: Identify stateless authentication methods

    JWTs carry all auth info in each request, no server session needed.
  2. Step 2: Compare with session-based methods

    Session-based methods like storing sessions on the server or keeping login state break statelessness.
  3. Final Answer:

    Use JSON Web Tokens (JWT) sent with each request for authentication -> Option C
  4. Quick Check:

    JWT enables stateless authentication [OK]
Quick Trick: JWTs keep REST APIs stateless with auth [OK]
Common Mistakes:
  • Choosing server session storage
  • Relying on cookies with server sessions
  • Assuming login once is enough

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes