13

I'm trying to understand what are the available claims I am able to access from the API Gateway when an user makes an authenticated request.

The API Gateway Mapping Template Reference (https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html#context-variable-reference) is listing different authorizer claims but it looks like only "sub" and "email" work.

All the other claims are logged as "-"

I'm logging the requests with CloudWatch, as described in this guide: https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-logging.html

I would like to get the username too but none of the following mapping work:

  • $context.authorizer.claims['cognito:username']
  • $context.authorizer.claims\['cognito:username'\]
  • $context.identity.cognitoIdentityId
Gnafu
  • 1,591
  • 3
  • 10
  • 26

1 Answers1

0

To see a list of all available properties you can temporarily add this to your mapping template: $context.authorizer.claims.keySet().

Chris Smith
  • 592
  • 3
  • 9