'how to call aws api gateway authorized

How can I invoke an API call of AWS API Gateway from python? The api is secured with an authorizer setup with cognito.

I can authenticate with a cognito-idp like shown this:

response = client.initiate_auth(
    ClientId=CLIENT_ID,
    AuthFlow="USER_PASSWORD_AUTH",
    AuthParameters={"USERNAME": username, "PASSWORD": password},
)

and I get a AccessToken from that. But how do I use that for a request? My API is something like

https://api_id.execute-api.mydomain.tld/dev/get_database_entry/

and I try calling it with requests:

response = requests.get(API_URL, auth=[??])


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source