You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
🐣 Is your feature request related to a problem? Please describe.
The server I am authenticating against uses bearer token for the authentication header. For that I like to use a custom auth class and use it with a dedicated ClientSession as the auth parameter.
Regarding ClientSession this is only a type hint issue but down in ClientRequest.update_auth the instance check for BasicAuth brakes my approach.
💡 Describe the solution you'd like
It feels that the auth instance only needs to have an encode method to work. Because of that I'd propose defining a protocol for auth and do an instance check on that.
However, it does not lead to a satisfactory solution, because aiohttp.BasicAuth inherits from a namedtuple and calls the __new__ method which will build the named tuple with login=token, password='', encoding='latin1'. Afterwards the __init__ method will set the token attribute.
I would prefer an ABC for deriving user specific authentications, because encode is a very common class method name, e.g. str. The ABC would prevent any misuse.
🐣 Is your feature request related to a problem? Please describe.
The server I am authenticating against uses bearer token for the authentication header. For that I like to use a custom auth class and use it with a dedicated
ClientSession
as theauth
parameter.Regarding
ClientSession
this is only a type hint issue but down inClientRequest.update_auth
the instance check forBasicAuth
brakes my approach.💡 Describe the solution you'd like
It feels that the auth instance only needs to have an
encode
method to work. Because of that I'd propose defining a protocol for auth and do an instance check on that.❓ Describe alternatives you've considered
The proposed solution only works with >= Python 3.8. Other alternatives that come to mind are:
The text was updated successfully, but these errors were encountered: