Complete the code to check if the incoming request has an Authorization header.
if not request.headers.get([1]): return 'Unauthorized', 401
The gateway must check the 'Authorization' header to authenticate requests.
Complete the code to extract the token from the Authorization header.
token = request.headers.get('Authorization').[1](' ')[1]
The token is usually after the word 'Bearer' separated by a space, so splitting by space and taking the second part extracts the token.
Fix the error in the code to validate the token using the gateway's auth service.
is_valid = auth_service.[1](token)The method to check token validity is typically named 'validate_token' in auth services.
Fill both blanks to reject requests without valid tokens and allow valid ones.
if not [1]: return [2], 401
If the token is not valid (is_valid is False), the gateway returns 'Unauthorized' with status 401.
Fill all three blanks to forward the authenticated request with user info to microservices.
request.headers['X-User-ID'] = [1] request.headers['X-User-Role'] = [2] response = microservice_client.[3](request)
The gateway adds user ID and role headers extracted from the token, then forwards the request using 'send_request' method.