1

In lambda authorizer, the http status code returned for access denied, token expired etc are 403. How do i return a message 'Token Expired' in case the Token Expires.

context.fail method is not supported. Raise Exception only creates log in cloudwatch.

def lambda_handler(event, context):
    .
    .
    .
    # verify the signature
    claims = jwt.get_unverified_claims(token)
    if time.time() > claims['exp']:
        print('Token is expired')
        return generatePolicy(claims['sub'], 'Deny', event['methodArn'])
    else:
    if(claims['cognito:groups'][0].lower()=='admin'):
        return generatePolicy(claims['sub'], 'Allow', event['methodArn'])
    else:
        return generatePolicy(claims['sub'], 'Deny', event['methodArn'])
    return claims
  • Possible duplicate of [How to throw custom error message from API Gateway custom authorizer](https://stackoverflow.com/questions/47921803/how-to-throw-custom-error-message-from-api-gateway-custom-authorizer) – K Mo Aug 30 '19 at 08:12

0 Answers0