Skip to content

Commit 5f3cdd9

Browse files
committed
chore: Add optional parameters to AtlanClient.from_token_guid method
1 parent 6875532 commit 5f3cdd9

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

pyatlan/client/atlan.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,13 @@ def dq_template_config_cache(self) -> DQTemplateConfigCache:
360360
return self._dq_template_config_cache
361361

362362
@classmethod
363-
def from_token_guid(cls, guid: str) -> AtlanClient:
363+
def from_token_guid(
364+
cls,
365+
guid: str,
366+
base_url: Optional[str] = None,
367+
client_id: Optional[str] = None,
368+
client_secret: Optional[str] = None,
369+
) -> AtlanClient:
364370
"""
365371
Create an AtlanClient instance using an API token GUID.
366372
@@ -374,12 +380,14 @@ def from_token_guid(cls, guid: str) -> AtlanClient:
374380
:returns: a new client instance authenticated with the resolved token
375381
:raises: ErrorCode.UNABLE_TO_ESCALATE_WITH_PARAM: If any step in the token resolution fails
376382
"""
377-
base_url = os.environ.get("ATLAN_BASE_URL", "INTERNAL")
383+
base_url = base_url or os.environ.get("ATLAN_BASE_URL", "INTERNAL")
378384

379385
# Step 1: Initialize base client and get Atlan-Argo credentials
380386
# Note: Using empty api_key as we're bootstrapping authentication
381387
client = AtlanClient(base_url=base_url, api_key="")
382-
client_info = client.impersonate._get_client_info()
388+
client_info = client.impersonate._get_client_info(
389+
client_id=client_id, client_secret=client_secret
390+
)
383391

384392
# Prepare credentials for Atlan-Argo token request
385393
argo_credentials = {

pyatlan/client/impersonate.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,16 @@ def user(self, user_id: str) -> str:
6666
except AtlanError as atlan_err:
6767
raise ErrorCode.UNABLE_TO_IMPERSONATE.exception_with_parameters() from atlan_err
6868

69-
def _get_client_info(self) -> ClientInfo:
70-
client_id = os.getenv("CLIENT_ID")
71-
client_secret = os.getenv("CLIENT_SECRET")
72-
if not client_id or not client_secret:
69+
def _get_client_info(
70+
self, client_id: Optional[str] = None, client_secret: Optional[str] = None
71+
) -> ClientInfo:
72+
final_client_id = client_id or os.getenv("CLIENT_ID")
73+
final_client_secret = client_secret or os.getenv("CLIENT_SECRET")
74+
if not final_client_id or not final_client_secret:
7375
raise ErrorCode.MISSING_CREDENTIALS.exception_with_parameters()
74-
client_info = ClientInfo(client_id=client_id, client_secret=client_secret)
76+
client_info = ClientInfo(
77+
client_id=final_client_id, client_secret=final_client_secret
78+
)
7579
return client_info
7680

7781
def escalate(self) -> str:

0 commit comments

Comments
 (0)