aws-lambdaaws-api-gatewaylambda-authorizer

How to pass Lambda Authorizer context parameter to Backend API's


We have below architecture in our application.

enter image description here

I am able to verify Firebase IdToken with the help of Lambda Authorizer and able to fetch user detail like (email/phone number/ profile pic) using that token. I have added all these parameter in context and returning as well,

Map<String, String> ctx = new HashMap<String, String>();
    ctx.put("userId", userId);
    ctx.put("email",user.getEmail());
    ctx.put("phoneNumber",user.getPhoneNumber());

I have tested Lambda Authorizer (AWS UI), getting these parameters in the response.

How to pass these details from Lambda Authorizer to API Gateway to Backend API's (under API Gateway)?


Solution

  • We use Swagger to define and create our APIs. When doing this, we use the x-amazon-apigateway-integration.requestParameters object to send context parameters from the authorizer to the (backend) integration endpoint (as query parameters). If you're setting up your APIs in the console, you can do the same thing on each resource's Integration Request page, in the URL Query String Parameters section.

    Let me know if I can add any clarification to this answer.