Cadair / parfive

An asyncio based parallel file downloader for Python 3.8+

Home Page:https://parfive.readthedocs.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support HTTP Basic Auth

Cadair opened this issue · comments

This involves a way of passing arguments to aiohttp.ClientSession which means doing it at construct time (or via properties) as we only use one session per call to download().

Since the constructor of aiohttp.ClientSession allows an auth parameter, may we simply add the basic auth as an instance variable to Downloader?

I don't want to replicate the whole aiohttp.ClientSession signature in Download() so maybe we should just allow a http_session dictionary which gets passed through or something?

Eitherway, we really need to document how to pass what kwargs to what through parfive.

Why don't we pass the session to the downloader? This would give more freedom down the line. Whatever the kind of auth is, the user can do the auth and pass the corresponding session down to the downloader?

Thanks for this project. Could you please provide one example of how to use HTTP Auth with SessionConfig.

Found the solution myself:

gen = lambda config: aiohttp.ClientSession(auth=aiohttp.BasicAuth(login=LOGIN, password=PASSWORD))

dl = Downloader(progress=True, config=SessionConfig(
    aiohttp_session_generator=gen
))