@@ -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
@@ -371,15 +377,20 @@ def from_token_guid(cls, guid: str) -> AtlanClient:
371377 4. Returns a new AtlanClient authenticated with the resolved token
372378
373379 :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)
374383 :returns: a new client instance authenticated with the resolved token
375384 :raises: ErrorCode.UNABLE_TO_ESCALATE_WITH_PARAM: If any step in the token resolution fails
376385 """
377- base_url = os .environ .get ("ATLAN_BASE_URL" , "INTERNAL" )
386+ final_base_url = base_url or os .environ .get ("ATLAN_BASE_URL" , "INTERNAL" )
378387
379388 # Step 1: Initialize base client and get Atlan-Argo credentials
380389 # 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+ )
383394
384395 # Prepare credentials for Atlan-Argo token request
385396 argo_credentials = {
@@ -393,7 +404,7 @@ def from_token_guid(cls, guid: str) -> AtlanClient:
393404 try :
394405 raw_json = client ._call_api (GET_TOKEN , request_obj = argo_credentials )
395406 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 )
397408 except AtlanError as atlan_err :
398409 raise ErrorCode .UNABLE_TO_ESCALATE_WITH_PARAM .exception_with_parameters (
399410 "Failed to obtain Atlan-Argo token"
@@ -419,7 +430,7 @@ def from_token_guid(cls, guid: str) -> AtlanClient:
419430 token_api_key = AccessTokenResponse (** raw_json ).access_token
420431
421432 # 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 )
423434 except AtlanError as atlan_err :
424435 raise ErrorCode .UNABLE_TO_ESCALATE_WITH_PARAM .exception_with_parameters (
425436 "Failed to obtain access token for API token"
0 commit comments