'How to send AWSRequestsAuth via asyncio?
Using the requests library, i can send requests to aws api gateway and pass an AWSRequestsAuth object. Behind the scenes this object inherites requests.auth.AuthBase.
I create an object like this:
auth = AWSRequestsAuth(
aws_access_key=settings.aws_access_key,
aws_secret_access_key=settings.aws_secret_access_key,
aws_host=AWS_API_HOST,
aws_region='eu-west-1',
aws_service='execute-api'
)
then I send it with requests.post(url, data, auth=auth).
When using asyncio, I try:
async def main():
async with aiohttp.ClientSession() as session:
async with session.post(
url,
data=data,
auth=auth
) as resp:
status = await resp.json()
print(status)
But I get the error TypeError: BasicAuth() tuple is required instead.
How can I send a request to aws gateway using auth, via asyncio?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
