Replies: 1 comment
-
Hi @OzyOzk, This information is accessible in a couple of places throughout the request cycle. The first place might be from the @app.get("/")
def home(request: Request):
event = request.scope["aws.event"]
username = event["requestContext"]["authorizer"]["jwt"]["claims"]["username"]
... The other might be if you need to do something with it prior to application being run: def handler(event, context):
username = event["requestContext"]["authorizer"]["jwt"]["claims"]["username"]
# Maybe you need to do something based on this information before running the application.
if username == "my-condition":
...
# Return the response from the application via the handler.
asgi_handler = Mangum(app)
response = asgi_handler(event, context) # Call the instance with the event arguments
return response More info in https://mangum.io/adapter/. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In my lambda function, I'm using a custom router to handle the endpoints from API gateway. If I were to switch to FastAPI and Mangum, how would I access the authorizer name so that I can determine who is making the API call?
At the moment I do username = event["requestContext"]["authorizer"]["jwt"]["claims"]["username"].
Does Mangum provide this info. Looking through the code it does not seem to.
Beta Was this translation helpful? Give feedback.
All reactions