如何在API Gateway Cloudwatch中记录所有Cognito用户详细信息

Gna*_*afu 5 amazon-web-services amazon-cognito aws-api-gateway amazon-cloudwatchlogs aws-cognito

我试图了解当用户发出经过身份验证的请求时,我可以从API网关访问的可用声明是什么。

API网关映射模板参考(https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html#context-variable-reference)列出了不同的授权者声明,但它看起来只有“ sub”和“ email”工作。

所有其他声明都记录为“-”

我正在使用CloudWatch记录请求,如本指南中所述:https ://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-logging.html

我也想获取用户名,但以下映射均无效:

  • $ context.authorizer.claims ['cognito:username']
  • $ context.authorizer.claims \ ['cognito:username'\]
  • $ context.identity.cognitoIdentityId

Chr*_*ith 0

要查看所有可用属性的列表,您可以临时将其添加到映射模板中:$context.authorizer.claims.keySet()