@@ -1618,6 +1618,37 @@ def test_client_401_token_refresh(
16181618 assert results and results .count >= 1
16191619
16201620
1621+ def test_client_init_from_token_guid (
1622+ client : AtlanClient , token : ApiToken , argo_fake_token : ApiToken , monkeypatch
1623+ ):
1624+ # In real-world scenarios, these values come from environment variables
1625+ # configured at the Argo template level. The SDK uses these values to
1626+ # create a temporary client, which allows us to find the `client_id` and `client_secret`
1627+ # for the provided API token GUID, later used to initialize a client with its actual access token (API key) <- AtlanClient.from_token_guid()
1628+ assert argo_fake_token and argo_fake_token .guid
1629+ argo_client_secret = client .impersonate .get_client_secret (
1630+ client_guid = argo_fake_token .guid
1631+ )
1632+ monkeypatch .setenv ("CLIENT_ID" , argo_fake_token .client_id )
1633+ monkeypatch .setenv ("CLIENT_SECRET" , argo_client_secret )
1634+
1635+ # Ensure it's a valid API token
1636+ assert token and token .username and token .guid
1637+ assert "service-account" in token .username
1638+ token_client = AtlanClient .from_token_guid (guid = token .guid )
1639+
1640+ # Should be able to perform all operations
1641+ # with this client as long as it has the necessary permissions
1642+ results = (
1643+ FluentSearch ()
1644+ .where (CompoundQuery .active_assets ())
1645+ .where (CompoundQuery .asset_type (AtlasGlossary ))
1646+ .page_size (100 )
1647+ .execute (client = token_client )
1648+ )
1649+ assert results and results .count >= 1
1650+
1651+
16211652def test_process_assets_when_no_assets_found (client : AtlanClient ):
16221653 def should_never_be_called (_ : Asset ):
16231654 pytest .fail ("Should not be called" )
0 commit comments