openapi-python-client
openapi-python-client copied to clipboard
Support other authentication methods
Is your feature request related to a problem? Please describe. The clients I'm generating must authenticate with a cookie, which is not supported by openapi-python-client right now.
Describe the solution you'd like One of:
- retrieving the authentication method from the spec (is this possible?) and generating the client accordingly
- accept options on the command line to specify the authentication method
Describe alternatives you've considered Manually altering the generated client. This is what I currently have:
@dataclass
class AuthenticatedClient(Client):
token: str
def get_headers(self) -> Dict[str, str]:
return {}
def get_cookies(self) -> Dict[str, str]:
return {"auth_cookie_name": self.token}
Then I added cookies=client.get_cookies()
to every request made using httpx in the api modules.
So in the long term, yeah we should totally parse as much info as possible about the security method via the OpenAPI Document and maybe generate a different AuthenticatedClient variant for each method.
In the near term, for 0.6.0, I'll add in a generic get_cookies() to the Clients so it's easier to pass things in in the future.
There are other discussions tracking individual security scheme improvements, so closing this to defer to each implementation.