Skip to content

Commit a206173

Browse files
Add file_oidc
1 parent e7ffdce commit a206173

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

databricks/sdk/config.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,11 @@
1414
from ._base_client import _fix_host_if_needed
1515
from .clock import Clock, RealClock
1616
from .credentials_provider import CredentialsStrategy, DefaultCredentials
17-
from .environments import ALL_ENVS, AzureEnvironment, Cloud, DatabricksEnvironment, get_environment_for_hostname
18-
from .oauth import (
19-
OidcEndpoints,
20-
Token,
21-
get_account_endpoints,
22-
get_azure_entra_id_workspace_endpoints,
23-
get_workspace_endpoints,
24-
)
17+
from .environments import (ALL_ENVS, AzureEnvironment, Cloud,
18+
DatabricksEnvironment, get_environment_for_hostname)
19+
from .oauth import (OidcEndpoints, Token, get_account_endpoints,
20+
get_azure_entra_id_workspace_endpoints,
21+
get_workspace_endpoints)
2522

2623
logger = logging.getLogger("databricks.sdk")
2724

databricks/sdk/credentials_provider.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,9 @@ def runtime_native_auth(cfg: "Config") -> Optional[CredentialsProvider]:
151151
# This import MUST be after the "DATABRICKS_RUNTIME_VERSION" check
152152
# above, so that we are not throwing import errors when not in
153153
# runtime and no config variables are set.
154-
from databricks.sdk.runtime import init_runtime_legacy_auth, init_runtime_native_auth, init_runtime_repl_auth
154+
from databricks.sdk.runtime import (init_runtime_legacy_auth,
155+
init_runtime_native_auth,
156+
init_runtime_repl_auth)
155157

156158
for init in [
157159
init_runtime_native_auth,
@@ -319,6 +321,9 @@ def env_oidc(cfg) -> Optional[CredentialsProvider]:
319321

320322
return _oidc_credentials_provider(cfg, oidc.EnvIdTokenSource(env_var))
321323

324+
@credentials_strategy("file-oidc", ["host", "oidc_token_filepath"])
325+
def file_oidc(cfg) -> Optional[CredentialsProvider]:
326+
return _oidc_credentials_provider(cfg, oidc.FileIdTokenSource(cfg.oidc_token_filepath))
322327

323328
# This function is a helper function to create an OIDC CredentialsProvider
324329
# that provides a Databricks token from an IdTokenSource.
@@ -1006,6 +1011,7 @@ def __init__(self) -> None:
10061011
metadata_service,
10071012
oauth_service_principal,
10081013
env_oidc,
1014+
file_oidc,
10091015
github_oidc,
10101016
azure_service_principal,
10111017
github_oidc_azure,

0 commit comments

Comments
 (0)