From b292573b5130504e37ce36e3ae28e5e37ecbd671 Mon Sep 17 00:00:00 2001 From: Amina Tadjer <141734868+atadj@users.noreply.github.com> Date: Wed, 18 Feb 2026 12:18:24 +0100 Subject: [PATCH 1/4] add .idea to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index a10b609..a0d595e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ __pycache__/ *.py[cod] .DS_Store +.idea* *~ _venv venv From 2db6f90676792888afd0f5cad24cf9341ede0593 Mon Sep 17 00:00:00 2001 From: Amina Tadjer <141734868+atadj@users.noreply.github.com> Date: Wed, 18 Feb 2026 15:47:13 +0100 Subject: [PATCH 2/4] add authenticate using azure client id --- src/sumo/wrapper/sumo_client.py | 47 +++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/src/sumo/wrapper/sumo_client.py b/src/sumo/wrapper/sumo_client.py index 349e59e..a21bacc 100644 --- a/src/sumo/wrapper/sumo_client.py +++ b/src/sumo/wrapper/sumo_client.py @@ -35,7 +35,7 @@ class SumoClient: def __init__( self, - env: str, + env: str = "prod", token: Optional[str] = None, interactive: bool = True, devicecode: bool = False, @@ -65,10 +65,10 @@ def __init__( tenant_id = well_known["tenant_id"] authority_host = well_known["authority"] config = well_known["envs"][env] - client_id = config["client_id"] + config_client_id = config["client_id"] resource_id = config["resource_id"] base_url = config["base_url"] - + azure_client_id = os.environ.get("AZURE_CLIENT_ID") self.env = env self._verbosity = verbosity @@ -113,17 +113,36 @@ def __init__( pass cleanup_shared_keys() - - self.auth = get_auth_provider( - client_id=client_id, - authority=f"{authority_host}{tenant_id}", - resource_id=resource_id, - interactive=interactive, - refresh_token=refresh_token, - access_token=access_token, - devicecode=devicecode, - case_uuid=case_uuid, - ) + if azure_client_id: + try: + self.auth = get_auth_provider( + client_id=azure_client_id, + authority=f"{authority_host}{tenant_id}", + resource_id=resource_id, + interactive=interactive, + refresh_token=refresh_token, + access_token=access_token, + devicecode=devicecode, + case_uuid=case_uuid, + ) + token = self.auth.get_token() + if token is None: + raise ValueError( + f"Authentication failed with the provided AZURE_CLIENT_ID: {azure_client_id}" + ) + except Exception as e: + logger.error(f"Authentication failed. Error: {e}") + else: + self.auth = get_auth_provider( + client_id=config_client_id, + authority=f"{authority_host}{tenant_id}", + resource_id=resource_id, + interactive=interactive, + refresh_token=refresh_token, + access_token=access_token, + devicecode=devicecode, + case_uuid=case_uuid, + ) self.base_url = base_url return From e158c6632aceb5aed7358b715b2f30e809424c54 Mon Sep 17 00:00:00 2001 From: Amina Tadjer <141734868+atadj@users.noreply.github.com> Date: Thu, 19 Feb 2026 12:05:41 +0100 Subject: [PATCH 3/4] feat: add client_id to the constructor --- src/sumo/wrapper/sumo_client.py | 49 ++++++++++++--------------------- 1 file changed, 17 insertions(+), 32 deletions(-) diff --git a/src/sumo/wrapper/sumo_client.py b/src/sumo/wrapper/sumo_client.py index a21bacc..4b83f96 100644 --- a/src/sumo/wrapper/sumo_client.py +++ b/src/sumo/wrapper/sumo_client.py @@ -36,6 +36,7 @@ class SumoClient: def __init__( self, env: str = "prod", + client_id: Optional[str] = None, token: Optional[str] = None, interactive: bool = True, devicecode: bool = False, @@ -50,6 +51,7 @@ def __init__( Args: env: Sumo environment + client_id: Client ID for authentication. If None, will use AZURE_CLIENT_ID from environment variables or the config token: Access token or refresh token. interactive: Enable interactive authentication (in browser). If not enabled, code grant flow will be used. @@ -65,10 +67,13 @@ def __init__( tenant_id = well_known["tenant_id"] authority_host = well_known["authority"] config = well_known["envs"][env] - config_client_id = config["client_id"] resource_id = config["resource_id"] base_url = config["base_url"] - azure_client_id = os.environ.get("AZURE_CLIENT_ID") + self.client_id = ( + client_id + or os.environ.get("AZURE_CLIENT_ID") + or config["client_id"] + ) self.env = env self._verbosity = verbosity @@ -113,36 +118,16 @@ def __init__( pass cleanup_shared_keys() - if azure_client_id: - try: - self.auth = get_auth_provider( - client_id=azure_client_id, - authority=f"{authority_host}{tenant_id}", - resource_id=resource_id, - interactive=interactive, - refresh_token=refresh_token, - access_token=access_token, - devicecode=devicecode, - case_uuid=case_uuid, - ) - token = self.auth.get_token() - if token is None: - raise ValueError( - f"Authentication failed with the provided AZURE_CLIENT_ID: {azure_client_id}" - ) - except Exception as e: - logger.error(f"Authentication failed. Error: {e}") - else: - self.auth = get_auth_provider( - client_id=config_client_id, - authority=f"{authority_host}{tenant_id}", - resource_id=resource_id, - interactive=interactive, - refresh_token=refresh_token, - access_token=access_token, - devicecode=devicecode, - case_uuid=case_uuid, - ) + self.auth = get_auth_provider( + client_id=self.client_id, + authority=f"{authority_host}{tenant_id}", + resource_id=resource_id, + interactive=interactive, + refresh_token=refresh_token, + access_token=access_token, + devicecode=devicecode, + case_uuid=case_uuid, + ) self.base_url = base_url return From 65744f982a74d48cda6fc9701a6e5ccf7b1d1294 Mon Sep 17 00:00:00 2001 From: Amina Tadjer <141734868+atadj@users.noreply.github.com> Date: Thu, 19 Feb 2026 12:54:15 +0100 Subject: [PATCH 4/4] feat: change client_id order in __init__ --- src/sumo/wrapper/sumo_client.py | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/sumo/wrapper/sumo_client.py b/src/sumo/wrapper/sumo_client.py index 4b83f96..2a85339 100644 --- a/src/sumo/wrapper/sumo_client.py +++ b/src/sumo/wrapper/sumo_client.py @@ -36,7 +36,6 @@ class SumoClient: def __init__( self, env: str = "prod", - client_id: Optional[str] = None, token: Optional[str] = None, interactive: bool = True, devicecode: bool = False, @@ -46,16 +45,28 @@ def __init__( case_uuid=None, http_client=None, async_http_client=None, + client_id: Optional[str] = None, ): """Initialize a new Sumo object Args: - env: Sumo environment - client_id: Client ID for authentication. If None, will use AZURE_CLIENT_ID from environment variables or the config - token: Access token or refresh token. - interactive: Enable interactive authentication (in browser). - If not enabled, code grant flow will be used. - verbosity: Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL) + env (str): Sumo environment. Defaults to "prod". + token (Optional[str]): Access token or refresh token. Defaults to None. + interactive (bool): Enable interactive authentication (in browser). + If not enabled, code grant flow will be used. Defaults to True. + devicecode (bool): Enable device code flow. Defaults to False. + verbosity (str): Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL). + Defaults to "CRITICAL". + retry_strategy (RetryStrategy): Retry strategy for HTTP requests. + Defaults to RetryStrategy(). + timeout (int): Timeout for HTTP requests. Defaults to DEFAULT_TIMEOUT. + case_uuid (Optional[str]): Case UUID for authentication. Defaults to None. + http_client (Optional[httpx.Client]): HTTP client for synchronous requests. + Defaults to None. + async_http_client (Optional[httpx.AsyncClient]): HTTP client for asynchronous requests. + Defaults to None. + client_id (Optional[str]): Client ID for authentication. If None, will use + AZURE_CLIENT_ID from environment variables or the config. Defaults to None. """ logger.setLevel(verbosity)