Skip to content

Commit 2033684

Browse files
committed
[Feature] Support CLI Profiles for Unified Host
1 parent 6a56e8d commit 2033684

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

databricks/sdk/credentials_provider.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -430,9 +430,9 @@ def _oidc_credentials_provider(
430430

431431
# Determine the audience for token exchange
432432
audience = cfg.token_audience
433-
if audience is None and cfg.is_account_client:
433+
if audience is None and cfg.client_type.value == "account":
434434
audience = cfg.account_id
435-
if audience is None and not cfg.is_account_client:
435+
if audience is None and cfg.client_type.value != "account":
436436
audience = cfg.oidc_endpoints.token_endpoint
437437

438438
# Try to get an OIDC token. If no supplier returns a token, we cannot use this authentication mode.
@@ -589,7 +589,7 @@ def token() -> oauth.Token:
589589
def refreshed_headers() -> Dict[str, str]:
590590
credentials.refresh(request)
591591
headers = {"Authorization": f"Bearer {credentials.token}"}
592-
if cfg.is_account_client:
592+
if cfg.client_type.value == "account":
593593
gcp_credentials.refresh(request)
594594
headers["X-Databricks-GCP-SA-Access-Token"] = gcp_credentials.token
595595
return headers
@@ -630,7 +630,7 @@ def token() -> oauth.Token:
630630
def refreshed_headers() -> Dict[str, str]:
631631
id_creds.refresh(request)
632632
headers = {"Authorization": f"Bearer {id_creds.token}"}
633-
if cfg.is_account_client:
633+
if cfg.client_type.value == "account":
634634
gcp_impersonated_credentials.refresh(request)
635635
headers["X-Databricks-GCP-SA-Access-Token"] = gcp_impersonated_credentials.token
636636
return headers
@@ -852,7 +852,14 @@ class DatabricksCliTokenSource(CliTokenSource):
852852

853853
def __init__(self, cfg: "Config"):
854854
args = ["auth", "token", "--host", cfg.host]
855-
if cfg.is_account_client:
855+
if cfg.experimental_is_unified_host:
856+
# For unified hosts, pass account_id, workspace_id, and experimental flag
857+
args += ["--experimental-is-unified-host"]
858+
if cfg.account_id:
859+
args += ["--account-id", cfg.account_id]
860+
if cfg.workspace_id:
861+
args += ["--workspace-id", str(cfg.workspace_id)]
862+
elif cfg.client_type.value == "account":
856863
args += ["--account-id", cfg.account_id]
857864

858865
cli_path = cfg.databricks_cli_path

0 commit comments

Comments
 (0)