@@ -360,7 +360,13 @@ def dq_template_config_cache(self) -> DQTemplateConfigCache:
360
360
return self ._dq_template_config_cache
361
361
362
362
@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 :
364
370
"""
365
371
Create an AtlanClient instance using an API token GUID.
366
372
@@ -371,15 +377,20 @@ def from_token_guid(cls, guid: str) -> AtlanClient:
371
377
4. Returns a new AtlanClient authenticated with the resolved token
372
378
373
379
:param guid: API token GUID to resolve
380
+ :param base_url: Optional base URL for the Atlan service(overrides ATLAN_BASE_URL environment variable)
381
+ :param client_id: Optional client ID for authentication (overrides CLIENT_ID environment variable)
382
+ :param client_secret: Optional client secret for authentication (overrides CLIENT_SECRET environment variable)
374
383
:returns: a new client instance authenticated with the resolved token
375
384
:raises: ErrorCode.UNABLE_TO_ESCALATE_WITH_PARAM: If any step in the token resolution fails
376
385
"""
377
- base_url = os .environ .get ("ATLAN_BASE_URL" , "INTERNAL" )
386
+ final_base_url = base_url or os .environ .get ("ATLAN_BASE_URL" , "INTERNAL" )
378
387
379
388
# Step 1: Initialize base client and get Atlan-Argo credentials
380
389
# Note: Using empty api_key as we're bootstrapping authentication
381
- client = AtlanClient (base_url = base_url , api_key = "" )
382
- client_info = client .impersonate ._get_client_info ()
390
+ client = AtlanClient (base_url = final_base_url , api_key = "" )
391
+ client_info = client .impersonate ._get_client_info (
392
+ client_id = client_id , client_secret = client_secret
393
+ )
383
394
384
395
# Prepare credentials for Atlan-Argo token request
385
396
argo_credentials = {
@@ -393,7 +404,7 @@ def from_token_guid(cls, guid: str) -> AtlanClient:
393
404
try :
394
405
raw_json = client ._call_api (GET_TOKEN , request_obj = argo_credentials )
395
406
argo_token = AccessTokenResponse (** raw_json ).access_token
396
- temp_argo_client = AtlanClient (base_url = base_url , api_key = argo_token )
407
+ temp_argo_client = AtlanClient (base_url = final_base_url , api_key = argo_token )
397
408
except AtlanError as atlan_err :
398
409
raise ErrorCode .UNABLE_TO_ESCALATE_WITH_PARAM .exception_with_parameters (
399
410
"Failed to obtain Atlan-Argo token"
@@ -419,7 +430,7 @@ def from_token_guid(cls, guid: str) -> AtlanClient:
419
430
token_api_key = AccessTokenResponse (** raw_json ).access_token
420
431
421
432
# Step 5: Create and return the authenticated client
422
- return AtlanClient (base_url = base_url , api_key = token_api_key )
433
+ return AtlanClient (base_url = final_base_url , api_key = token_api_key )
423
434
except AtlanError as atlan_err :
424
435
raise ErrorCode .UNABLE_TO_ESCALATE_WITH_PARAM .exception_with_parameters (
425
436
"Failed to obtain access token for API token"
0 commit comments