- Più recenti
- Maggior numero di voti
- Maggior numero di commenti
You're right, API Gateway by default doesn't support headers with underscores. There are a few workarounds you can explore to handle the access_token header with an underscore in your SAM CLI-created API Gateway.
-
Custom Authorizer (Limited Functionality): Implement a custom authorizer function in your Lambda integration. This function can access the original request headers before any modifications by API Gateway. However, custom authorizers can only access a limited set of headers, and access_token might not be included.Just check once by giving it a try.
-
Custom Lambda Integration : This approach involves creating a custom Lambda integration for your API endpoint. The Lambda function will receive the unmodified request from API Gateway, allowing you to access the original header (access_token) with the underscore. Here's how to implement it: **step 1 : **Create a Lambda Function: This function will handle the request logic and access the original header. **step 2 **: Configure API Gateway Integration: Set the integration type to "AWS_PROXY" and choose your Lambda function as the integration target.
Within your Lambda function, you can access the original request headers, including the one with the underscore, using the event.headers dictionary.
Contenuto pertinente
- AWS UFFICIALEAggiornata un anno fa
- AWS UFFICIALEAggiornata 2 anni fa
- AWS UFFICIALEAggiornata 3 anni fa
- AWS UFFICIALEAggiornata 2 anni fa
I have tried with the Custom Authorizer and with the Custom Lambda Integration (integration type "AWS_PROXY"), but in both approaches, the headers are removed before they reach the Lambda function.
I need access to the access_token in the Custom Authorizer, but it was removed before it made it to the lambda function. I read that we can use CloudFront to intercept the header before it makes it to the API Gateway and replace the underscores with hyphens, but I want to leave the current request process as is and try to solve it on our own.