Bird
0
0

Consider this simplified code snippet for service-to-service authentication using JWT:

medium📝 Analysis Q13 of 15
Microservices - Authentication and Authorization
Consider this simplified code snippet for service-to-service authentication using JWT:
token = auth_server.issue_token(service_id="serviceA")
if auth_server.verify_token(token):
    print("Access granted")
else:
    print("Access denied")
What will be printed if the token is valid?
AAccess denied
BError: token missing
CAccess granted
DNo output
Step-by-Step Solution
Solution:
  1. Step 1: Understand token issuance and verification

    The token is issued by the auth server and then verified immediately.
  2. Step 2: Check the conditional logic

    If the token is valid, verify_token returns True, so "Access granted" is printed.
  3. Final Answer:

    Access granted -> Option C
  4. Quick Check:

    Valid token means access granted [OK]
Quick Trick: Valid token means verify_token returns True [OK]
Common Mistakes:
MISTAKES
  • Assuming token is invalid without checking
  • Confusing print outputs
  • Ignoring the if-else structure

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Microservices Quizzes