Is your feature request related to a problem? Please describe.
OpenAPI 3 supports expressing basic auth support: https://swagger.io/docs/specification/authentication/basic-authentication/
While basic auth is often not ideal for production, during development basic auth can be quite handy. Currently it is not possible to directly use basic auth with the generated Python client.
Describe the solution you'd like
Detect if an API supports basic auth and provide it as an alternative AuthenticatedClient.
An example implementation:
frombase64importb64encodefromtypingimportDictimportattr@attr.s(auto_attribs=True)classBasicAuthAuthenticatedClient(Client):
"""A Client which has been authenticated for use on secured endpoints"""username: strpassword: strdefget_headers(self) ->Dict[str, str]:
"""Get headers to be used in authenticated endpoints"""encoded_credentials=b64encode(f"{self.username}:{self.password}".encode()).decode()
return {"Authorization": f"Basic {encoded_credentials}", **self.headers}Describe alternatives you've considered
The AuthenticatedClient could be made to take either a token or username/password.
Is your feature request related to a problem? Please describe.
OpenAPI 3 supports expressing basic auth support: https://swagger.io/docs/specification/authentication/basic-authentication/
While basic auth is often not ideal for production, during development basic auth can be quite handy. Currently it is not possible to directly use basic auth with the generated Python client.
Describe the solution you'd like
Detect if an API supports basic auth and provide it as an alternative
AuthenticatedClient.An example implementation:
Describe alternatives you've considered
The
AuthenticatedClientcould be made to take either atokenorusername/password.