From 53b92c30fa85a64dd3bbcf56a44da3efe3f5d053 Mon Sep 17 00:00:00 2001 From: Andrew Teixeira Date: Fri, 13 Mar 2026 16:41:32 -0400 Subject: [PATCH] feat: Add the ability to pass a requests Session to Client fixes #254 --- cert_manager/client.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cert_manager/client.py b/cert_manager/client.py index b5b0785..9c04f1d 100644 --- a/cert_manager/client.py +++ b/cert_manager/client.py @@ -40,6 +40,8 @@ def __init__(self, **kwargs): auth_url: The full URL to the Sectigo OAuth2 token endpoint; the default is "https://auth.sso.sectigo.com/auth/realms/apiclients/protocol/openid-connect/token" client_id: The Client ID to use for OAuth2 authentication client_secret: The Client Secret to use for OAuth2 authentication + session: A requests.Session object to use instead of creating a new one; the default is None, + which will create a new session """ # Initialize class variables self._base_url = None @@ -51,7 +53,8 @@ def __init__(self, **kwargs): self._user_key_file = None self._username = None - self._session = requests.Session() + self._session = kwargs.get("session", requests.Session()) + # Set the default HTTP headers self._headers = { "Accept": "application/json",