B. Missing secret key in serializer initialization
C. max_age parameter is invalid in loads()
D. Using dumps() instead of loads() to verify
Solution
Step 1: Check token generation and usage
The token is generated inside generate_token but not stored or passed outside.
Step 2: Verify token usage scope
At verification, token is used but not defined in that scope, causing a NameError.
Final Answer:
Token variable is undefined at verification -> Option A
Quick Check:
Undefined token variable causes error [OK]
Hint: Ensure token variable is defined before verification [OK]
Common Mistakes:
Ignoring variable scope for token
Thinking secret key is missing
Misusing max_age parameter
5. You want to implement email verification in Flask so that users receive a link with a token that expires after 24 hours. Which approach correctly combines token creation, sending email, and verification?
hard
A. Generate token without secret key, send email, verify token ignoring expiration
B. Store plain email in database, send email without token, verify by matching email only
C. Send token as plain text in email body, verify token with max_age=3600
D. Generate token with URLSafeTimedSerializer, send email with token link, verify token with max_age=86400
Solution
Step 1: Create token with expiration
Use URLSafeTimedSerializer with a secret key to generate a token that expires after 86400 seconds (24 hours).
Step 2: Send email with token link and verify properly
Send the token inside a URL link in the email. Verify the token using loads() with max_age=86400 to enforce expiration.
Final Answer:
Generate token with URLSafeTimedSerializer, send email with token link, verify token with max_age=86400 -> Option D
Quick Check:
Token creation + email + 24h expiry = Generate token with URLSafeTimedSerializer, send email with token link, verify token with max_age=86400 [OK]
Hint: Use max_age=86400 for 24h token expiry [OK]
Common Mistakes:
Not using tokens in email links
Ignoring token expiration
Sending tokens without secret key
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.