- Newest
- Most votes
- Most comments
Based on your screenshots and description, this appears to be a permissions issue between API Gateway and your endpoint Lambda (not the authorizer Lambda). Here's how to fix it:
- Check your endpoint Lambda's resource policy. Add permission for API Gateway to invoke it:
aws lambda add-permission \ --function-name "your-endpoint-lambda-name" \ --statement-id "api-gateway-permission" \ --action "lambda:InvokeFunction" \ --principal "apigateway.amazonaws.com" \ --source-arn "arn:aws:execute-api:region:account-id:api-id/*/*/*"
-
Or add it through the AWS Console:
- Go to your endpoint Lambda
- Select 'Configuration' > 'Permissions'
- Check resource-based policy
- Add permission for API Gateway
-
Verify the API Gateway role has:
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "lambda:InvokeFunction", "Resource": "arn:aws:lambda:region:account-id:function:your-lambda-function" } ] }
The authorizer is working (as shown by your test), but API Gateway can't invoke your endpoint Lambda after authorization succeeds. This is a separate permission from the authorizer Lambda permissions.
For more details, see: API Gateway Permissions Documentation
Based on the information provided, it appears that you're experiencing an issue with API Gateway Lambda authorization. The problem seems to occur after the authorization is successful, suggesting that the issue may lie in how the authorized request is being handled or passed to the backend.
Here are some potential areas to investigate:
-
Lambda Function Permissions: Ensure that the Lambda function associated with your API endpoint (not the authorizer) has the necessary permissions to be invoked by API Gateway. Check the function's resource-based policy to confirm it allows API Gateway to invoke it.
-
API Gateway Configuration: Verify that the integration between API Gateway and your backend Lambda function is set up correctly. This includes checking the integration type, Lambda function ARN, and execution role.
-
IAM Roles: Review the IAM role attached to your API Gateway. Make sure it has the necessary permissions to invoke the Lambda function.
-
Lambda Authorizer Configuration: Double-check the Lambda authorizer settings in API Gateway. Ensure that the authorizer is correctly configured to pass the necessary context to the backend, including any required claims or principal identifiers.
-
CORS Settings: If your API is being called from a different domain, verify that CORS is properly configured in API Gateway.
-
API Gateway Stages: Confirm that your API is deployed to the correct stage and that the stage variables (if any) are properly set.
-
Lambda Function Error Handling: Review the error handling in your backend Lambda function. It's possible that the function is receiving the request but encountering an error that's not being properly caught or logged.
-
CloudWatch Logs: Check the CloudWatch logs for both the authorizer Lambda and the backend Lambda function to see if there are any error messages or unexpected behaviors not visible in the API Gateway test console.
-
API Gateway Method Execution: In the API Gateway console, use the Test feature on the Method Execution page to test each step of the request processing (Method Request, Integration Request, Integration Response, Method Response) to identify at which stage the request is failing.
Given that the authorizer test passes but the actual request fails, it's likely that the issue is occurring after authorization, possibly in how the authorized request is being processed or how it's being passed to your backend Lambda function. Carefully reviewing each of these areas should help you identify and resolve the issue.
Sources
Tutorial verbatim fails with Missing Authentication Token | AWS re:Post
x-amazon-apigateway-authtype property - Amazon API Gateway
answered a year ago
Relevant content
asked 2 years ago

I appreciate you time. I didn't have that resource-based permission set up. So I added it and same result. I confirmed in the logs that the correct policy is being passed back from authorization and it is.