in source/token-authorizer/chalice/app.py [0:0]
def api_gateway_authorizer(event, _):
"""
This function is a Lambda handler for an API Gateway custom authorizer
"""
token = event.get('authorizationToken', '')
arn = event.get('methodArn', '')
if arn and token:
# return a wildcard resource in the policy that covers all
# potential API requests while the response is cached
base_arn, _, _ = arn.split('/', 2)
resource = f"{base_arn}/*/*/*"
return check_authorizer_token(token, resource)
# no token or method ARN in the request
return Response(body='Request lacks valid authorization credentials',
status_code=401,
headers={'Content-Type': 'text/plain'})