QuizzesJWT — Creating and Verifying Tokens — Concept Check
intermediate
fastapi

JWT — Creating and Verifying Tokens — Concept Check

Questions on JWT — Creating and Verifying Tokens. A JWT is signed claims: jwt.encode() issues it with sub + exp, jwt.decode() verifies signature and expiry, and get_current_user turns all of it into one reusable dependency — with revocation as the honest trade-off.

7 minutes 7 questions Pass at 70%
Time Limit
7 minutes - timer starts when you begin
Change Answers Freely
Revisit and change any answer before submitting
Full Review After Submit
Correct answers and explanations shown for every question
Auto-submit on timeout
Quiz submits automatically when time runs out

Questions in this quiz

7 questions on JWT — Creating and Verifying Tokens — Concept Check. Work through them here, then start the quiz to answer them and see your score.

  1. 1.A developer uses jwt.encode() to create a token with sensitive user data in the payload. What is the risk?

    • AThe token cannot be decoded
    • BAnyone can read the sensitive data
    • CThe token can be easily tampered with
    • DThe token will not expire
  2. 2.A service is experiencing unauthorized access even after a user logs out. What could be the issue?

    • AThe algorithm used is insecure
    • BThe secret key is compromised
    • CJWTs are tamper-proof
    • DJWTs are valid until expiration
  3. 3.What happens if a JWT's exp claim is set to a past date?

    • AThe token can still be used until expiration
    • BThe token is valid until manually revoked
    • CThe token is immediately invalid
    • DThe token's signature is invalid
  4. 4.A developer wants to ensure immediate token revocation. What should they implement?

    • AHS256 algorithm pinning
    • BLong-lived access tokens
    • CStoring secrets in the payload
    • DToken versioning with DB checks
  5. 5.A token is decoded successfully but the user role is incorrect. What might be the cause?

    • AClaims were tampered with
    • BRole was not included in claims
    • CIncorrect secret key
    • DAlgorithm mismatch
  6. 6.Why is it important to pin algorithms=[ALGO] when decoding a JWT?

    • ATo prevent algorithm confusion attacks
    • BTo ensure the token expires
    • CTo make tokens tamper-proof
    • DTo allow any algorithm to be used
  7. 7.A user reports frequent logouts and has to re-login every 15 minutes. What is likely the issue?

    • ARefresh tokens are not used
    • BJWTs are not being decoded
    • CAccess tokens are too short-lived
    • DThe secret key is incorrect