Complete the code to extract the refresh token from the request headers.
refresh_token = request.headers.get([1])The refresh token is usually sent in a custom header like Refresh-Token. Using request.headers.get("Refresh-Token") retrieves it.
Complete the code to verify if the refresh token is valid before issuing a new access token.
if not verify_token([1]): return {'error': 'Invalid refresh token'}, 401
We verify the refresh_token to ensure it is valid before issuing a new access token.
Fix the error in the code that generates a new access token using the user ID from the refresh token payload.
user_id = decode_token([1])['user_id'] new_access_token = generate_access_token(user_id)
The refresh_token must be decoded to extract the user_id for generating a new access token.
Fill both blanks to create a JSON response with the new access token.
return { [1]: [2] }
The response should be a JSON object with the key access_token and the new token as its value.
Fill all three blanks to implement a complete token refresh endpoint that extracts, verifies, decodes, and returns a new access token.
def refresh_token_endpoint(request): [1] = request.headers.get("Refresh-Token") if not verify_token([2]): return {'error': 'Invalid refresh token'}, 401 user_id = decode_token([3])['user_id'] new_access_token = generate_access_token(user_id) return {'access_token': new_access_token}
All blanks should be filled with refresh_token to correctly handle the token refresh process.