Recall & Review
beginner
What is Token Authentication in Django REST Framework?
Token Authentication is a simple way to secure API endpoints by assigning a unique token to each user. The client sends this token with each request to prove their identity.
Click to reveal answer
beginner
What does JWT stand for and what is its main advantage?
JWT stands for JSON Web Token. Its main advantage is that it is self-contained, meaning it carries user information inside the token itself, allowing stateless authentication without server-side sessions.
Click to reveal answer
intermediate
How does Token Authentication differ from JWT Authentication in DRF?
Token Authentication uses a simple token stored on the server linked to a user, requiring server-side storage. JWT Authentication encodes user data in the token itself, so the server does not need to store session info, making it stateless.
Click to reveal answer
intermediate
How do you add Token Authentication to a DRF project?
Add 'rest_framework.authtoken' to INSTALLED_APPS, run migrations, and then include 'rest_framework.authentication.TokenAuthentication' in your REST_FRAMEWORK settings. Clients send the token in the 'Authorization' header as 'Token <token>'.
Click to reveal answer
intermediate
What is the typical structure of a JWT token?
A JWT token has three parts separated by dots: Header (algorithm info), Payload (user data and claims), and Signature (to verify token integrity). It looks like: header.payload.signature
Click to reveal answer
In DRF Token Authentication, where is the token stored?
✗ Incorrect
Token Authentication stores the token on the server linked to the user. The client sends this token to authenticate.
What header do clients use to send a JWT token in DRF?
✗ Incorrect
JWT tokens are sent in the 'Authorization' header with the prefix 'Bearer'.
Which of these is a benefit of JWT over Token Authentication?
✗ Incorrect
JWT tokens carry user info inside, so the server does not need to store session data, enabling stateless authentication.
Which Django app must be added to use Token Authentication in DRF?
✗ Incorrect
The 'rest_framework.authtoken' app provides Token Authentication support in DRF.
What are the three parts of a JWT token?
✗ Incorrect
A JWT token consists of Header, Payload, and Signature separated by dots.
Explain how Token Authentication works in Django REST Framework and how a client uses it.
Think about how the server and client share a secret token.
You got /3 concepts.
Describe the structure of a JWT token and why it allows stateless authentication.
JWT is like a sealed envelope carrying user info.
You got /4 concepts.