Skip to content

Retrieving JWT Claims from Amazon.Lambda.Annotations #1604

Discussion options

You must be logged in to vote

It appears I'd missed a trick! I'm not in a position to deploy and test this at the moment, but by using dotPeek, I could look at the generated code.

If I update my test function to accept the APIGatewayHttpApiV2ProxyRequest object, like so:

    [LambdaFunction]
    [HttpApi(LambdaHttpMethod.Get, "/add/{x}/{y}")]
    public int Add(int x, int y, ILambdaContext context, APIGatewayHttpApiV2ProxyRequest proxyRequest)
    {
        var emailClaim = proxyRequest.RequestContext.Authorizer.Jwt.Claims["emailID"];

        return x + y;
    }

I can see that the source generated code is:

public Amazon.Lambda.APIGatewayEvents.APIGatewayHttpApiV2ProxyResponse Add(Amazon.Lambda.APIGatewayEvents.APIG…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@danielwagstaff
Comment options

@danielwagstaff
Comment options

Answer selected by danielwagstaff
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
2 participants