🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: JWT and API Security: all 10 questions

Quiz: JWT and API Security · Question 10 of 10

What does this print? (code)

What does this print?

import base64, json
part = base64.urlsafe_b64encode(json.dumps({"role": "student"}).encode()).rstrip(b"=")
padded = part + b"=" * (-len(part) % 4)
print(json.loads(base64.urlsafe_b64decode(padded))["role"])
  1. A.It raises an error without the secret
  2. B.student
  3. C.admin
  4. D.None
Answer & explanation

Correct answer: student

Anyone can decode a JWT payload without the secret; only the signature needs it.

Can you get the rest right without peeking?

Take the timed Quiz: JWT and API Security quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →