@@ -350,7 +350,13 @@ def dq_template_config_cache(self) -> DQTemplateConfigCache:
350
350
return self ._dq_template_config_cache
351
351
352
352
@classmethod
353
- def from_token_guid (cls , guid : str ) -> AtlanClient :
353
+ def from_token_guid (
354
+ cls ,
355
+ guid : str ,
356
+ base_url : Optional [str ] = None ,
357
+ client_id : Optional [str ] = None ,
358
+ client_secret : Optional [str ] = None ,
359
+ ) -> AtlanClient :
354
360
"""
355
361
Create an AtlanClient instance using an API token GUID.
356
362
@@ -361,16 +367,20 @@ def from_token_guid(cls, guid: str) -> AtlanClient:
361
367
4. Returns a new AtlanClient authenticated with the resolved token
362
368
363
369
:param guid: API token GUID to resolve
370
+ :param base_url: Optional base URL for the Atlan service(overrides ATLAN_BASE_URL environment variable)
371
+ :param client_id: Optional client ID for authentication (overrides CLIENT_ID environment variable)
372
+ :param client_secret: Optional client secret for authentication (overrides CLIENT_SECRET environment variable)
364
373
:returns: a new client instance authenticated with the resolved token
365
374
:raises: ErrorCode.UNABLE_TO_ESCALATE_WITH_PARAM: If any step in the token resolution fails
366
375
"""
367
- base_url = os .environ .get ("ATLAN_BASE_URL" , "INTERNAL" )
376
+ final_base_url = base_url or os .environ .get ("ATLAN_BASE_URL" , "INTERNAL" )
368
377
369
378
# Step 1: Initialize base client and get Atlan-Argo credentials
370
379
# Note: Using empty api_key as we're bootstrapping authentication
371
- client = AtlanClient (base_url = base_url )
372
- client .api_key = ""
373
- client_info = ImpersonateUser .get_client_info ()
380
+ client = AtlanClient (base_url = final_base_url , api_key = "" )
381
+ client_info = client .impersonate ._get_client_info (
382
+ client_id = client_id , client_secret = client_secret
383
+ )
374
384
375
385
# Prepare credentials for Atlan-Argo token request
376
386
argo_credentials = {
@@ -384,7 +394,7 @@ def from_token_guid(cls, guid: str) -> AtlanClient:
384
394
try :
385
395
raw_json = client ._call_api (GET_TOKEN , request_obj = argo_credentials )
386
396
argo_token = AccessTokenResponse (** raw_json ).access_token
387
- temp_argo_client = AtlanClient (base_url = base_url , api_key = argo_token )
397
+ temp_argo_client = AtlanClient (base_url = final_base_url , api_key = argo_token )
388
398
except AtlanError as atlan_err :
389
399
raise ErrorCode .UNABLE_TO_ESCALATE_WITH_PARAM .exception_with_parameters (
390
400
"Failed to obtain Atlan-Argo token"
@@ -410,7 +420,7 @@ def from_token_guid(cls, guid: str) -> AtlanClient:
410
420
token_api_key = AccessTokenResponse (** raw_json ).access_token
411
421
412
422
# Step 5: Create and return the authenticated client
413
- return AtlanClient (base_url = base_url , api_key = token_api_key )
423
+ return AtlanClient (base_url = final_base_url , api_key = token_api_key )
414
424
except AtlanError as atlan_err :
415
425
raise ErrorCode .UNABLE_TO_ESCALATE_WITH_PARAM .exception_with_parameters (
416
426
"Failed to obtain access token for API token"
0 commit comments