Skip to content

Commit 9330fb7

Browse files
committed
feat: allow to configure auth_header_name and prefix in AuthenticatedClient
1 parent 7955faa commit 9330fb7

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

openapi_python_client/templates/client.py.jinja

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ class AuthenticatedClient(Client):
3939
""" A Client which has been authenticated for use on secured endpoints """
4040

4141
token: str
42+
prefix: str = "Bearer"
43+
auth_header_name: str = "Authorization"
4244

4345
def get_headers(self) -> Dict[str, str]:
44-
""" Get headers to be used in authenticated endpoints """
45-
return {"Authorization": f"Bearer {self.token}", **self.headers}
46+
auth_header_value = f"{self.prefix} {self.token}" if self.prefix else self.token
47+
"""Get headers to be used in authenticated endpoints"""
48+
return {self.auth_header_name: auth_header_value, **self.headers}

0 commit comments

Comments
 (0)