I was hoping for some beginner help with Clientsession. I successfully set up a simple https server using a locally signed cert for use in testing. I forget where I found the snippet I used as a basis for this, I think it was in the aio-libs docs, but I apologize to the author for failure to attribute:
from aiohttp import web import ssl routes = web.RouteTableDef() @routes.get('/') async def index(request): return web.FileResponse('./html/index.html') app = web.Application() app.add_routes(routes) app.router.add_static('/js/', path='./js', name='js') ssl_ctx = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH) ssl_ctx.load_cert_chain(certfile='certificate.pem', keyfile='key.pem',password=b'passphrase') web.run_app(app, ssl_context=ssl_ctx)
I’d like to now add a simple user login using Clientsession. I found an answered question on SO here and tried to integrate the following example into my code: aiohttp/client_auth.py at d55728da7486e0295a11bf2378a2eceb8fe39c64 · aio-libs/aiohttp · GitHub
Unfortunately this example uses the asyncio event loop as opposed to the web.application() framework (which is more in line with my use case). Can anyone help me understand how to add on Clientsession to manage client authorization in my example? I’m still wrapping my head around the current implementation of asyncio, which is part of the challenge for me in learning aio-libs.