From b82fa0119a8f85d913ac93a3700edc803b134ee0 Mon Sep 17 00:00:00 2001 From: Serge Smertin <259697+nfx@users.noreply.github.com> Date: Tue, 8 Aug 2023 19:10:30 +0200 Subject: [PATCH] Fixed OAuth M2M corner case in `WorkspaceClient` where `DATABRICKS_ACCOUNT_ID` is present in the environment (#273) ## Changes Also check for account client configuration when resolving OIDC endpoints. Now logic is the same as in Go SDK: https://github.com/databricks/databricks-sdk-go/blame/dd2802a246d8a2ac0689031cc93e15d97b486df8/config/auth_m2m.go#L45-L56 ## Tests Tested on a local change Signed-off-by: Serge Smertin <259697+nfx@users.noreply.github.com> --- databricks/sdk/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/databricks/sdk/core.py b/databricks/sdk/core.py index 149b551f..386ad325 100644 --- a/databricks/sdk/core.py +++ b/databricks/sdk/core.py @@ -640,7 +640,7 @@ def oidc_endpoints(self) -> Optional[OidcEndpoints]: return None return OidcEndpoints(authorization_endpoint=real_auth_url, token_endpoint=real_auth_url.replace('/authorize', '/token')) - if self.account_id: + if self.is_account_client and self.account_id: prefix = f'{self.host}/oidc/accounts/{self.account_id}' return OidcEndpoints(authorization_endpoint=f'{prefix}/v1/authorize', token_endpoint=f'{prefix}/v1/token')