Last active
July 1, 2024 15:27
-
-
Save djm/15cf09b6b21c20332a602d3bca6b6d08 to your computer and use it in GitHub Desktop.
Fix for AWS API Gateway Custom Authorizer Error => AuthorizerConfigurationException (message: null)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Solution (or at least one possible one): Your code is generating a policy with an invalid context. | |
For example, in Python, your authorizer might return: | |
return { | |
"principalId": principal_id, | |
"policyDocument": { | |
"Version": "2012-10-17", | |
"Statement": [ | |
{"Action": "execute-api:Invoke", "Effect": effect, "Resource": resource} | |
], | |
}, | |
"context": { | |
"some_nested_data": { | |
"id": 3 | |
}, | |
"user_id": 4, | |
}, | |
} | |
There are no valid keys in this example context. | |
The context _must_ abide by two rules: | |
1. All keys must be top level. No nested data. | |
2. All values must be strings, integers or booleans. | |
That means no setting nested JSON data to the context; and no making lists/arrays as the values. | |
When you get the data in your endpoint function, all the values will have been stringified. | |
Why? Absolutely fuck knows. Sorry, I can't help you there. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Life saver!