Reputation: 1672
I can't find a way to send user credentials with aiohttp. I want similar behavior to cURL's
curl --user "USER:PASSWORD"
but in aiohttp. On the reference doc I can't find this option, I can find query parameters, headers, body, but not user credentials.
I'm using aiohttp instead of curl for its asynchronous behavior.
Upvotes: 13
Views: 22493
Reputation: 20224
It is the same as using basic authentication.
So to use it in aiohttp
, you could use aiohttp.BasicAuth
. Somehow like:
async with client.get(url, auth=aiohttp.BasicAuth(user, password)) as resp:
assert resp.status == 200
print(await resp.text())
Upvotes: 25