Authentication Types Reference¶
This document lists all authentication types (auth_type) supported by the Databricks SDK for Python.
Authentication Types Table¶
Auth Type |
Description |
Required Parameters |
Optional Parameters |
Environment Variables |
|---|---|---|---|---|
|
Personal Access Token authentication - the most common method for programmatic access |
|
- |
|
|
Basic HTTP authentication using username and password (primarily for AWS) |
|
|
|
|
OAuth 2.0 Machine-to-Machine (service principal) authentication |
|
|
|
|
OAuth 2.0 authentication flow using local browser for user login |
|
|
|
|
Uses tokens from the Databricks CLI ( |
|
|
|
|
Azure Active Directory (AAD) Service Principal authentication |
|
|
|
|
Uses credentials from Azure CLI ( |
|
|
|
|
GitHub Actions OIDC authentication (workload identity federation) |
|
|
|
|
GitHub Actions OIDC for Azure Databricks workspaces |
|
|
|
|
Azure DevOps Pipelines OIDC authentication |
|
|
|
|
Google Cloud service account authentication using credentials JSON |
|
- |
|
|
Google Cloud authentication using service account impersonation |
|
- |
|
|
Authentication using Databricks-hosted metadata service |
|
- |
|
|
Auto-detected authentication when running in Databricks Runtime (notebooks, jobs) |
(auto-detected) |
- |
|
|
OAuth authentication for Databricks Runtime with fine-grained permissions |
|
|
|
|
Auto-detected authentication when running in Databricks Model Serving environment |
(auto-detected) |
- |
|
|
OIDC token from environment variable |
|
|
|
|
OIDC token from file path |
|
|
|
For configuration options that apply to all authentication types (timeouts, debug settings, rate limits), see Authentication.
Usage Examples¶
When you explicitly set auth_type, the SDK only attempts that authentication method, skipping the automatic detection of other methods. This is useful when you have multiple credentials configured but want to use a specific one.
Personal Access Token (PAT)¶
from databricks.sdk import WorkspaceClient
w = WorkspaceClient(
host="https://your-workspace.cloud.databricks.com",
token="dapi1234567890abcdef",
auth_type="pat"
)
Basic Authentication (Username/Password)¶
from databricks.sdk import WorkspaceClient
w = WorkspaceClient(
host="https://your-workspace.cloud.databricks.com",
username="your-username",
password="your-password",
auth_type="basic"
)
OAuth Machine-to-Machine (Service Principal)¶
from databricks.sdk import WorkspaceClient
w = WorkspaceClient(
host="https://your-workspace.cloud.databricks.com",
client_id="your-client-id",
client_secret="your-client-secret",
auth_type="oauth-m2m"
)
External Browser (OAuth for Users)¶
from databricks.sdk import WorkspaceClient
w = WorkspaceClient(
host="https://your-workspace.cloud.databricks.com",
auth_type="external-browser"
)
Databricks CLI¶
from databricks.sdk import WorkspaceClient
# Assumes you've run: databricks auth login --host https://your-workspace.cloud.databricks.com
w = WorkspaceClient(
host="https://your-workspace.cloud.databricks.com",
auth_type="databricks-cli"
)
Azure Service Principal¶
from databricks.sdk import WorkspaceClient
w = WorkspaceClient(
host="https://adb-1234567890.azuredatabricks.net",
azure_client_id="your-azure-client-id",
azure_client_secret="your-azure-client-secret",
azure_tenant_id="your-azure-tenant-id",
auth_type="azure-client-secret"
)
Azure CLI¶
from databricks.sdk import WorkspaceClient
# Assumes you've run: az login
w = WorkspaceClient(
host="https://adb-1234567890.azuredatabricks.net",
auth_type="azure-cli"
)
GitHub Actions OIDC¶
from databricks.sdk import WorkspaceClient
# In GitHub Actions with OIDC configured
w = WorkspaceClient(
host="https://your-workspace.cloud.databricks.com",
client_id="your-databricks-oauth-client-id",
auth_type="github-oidc"
)
GitHub Actions OIDC for Azure¶
from databricks.sdk import WorkspaceClient
# In GitHub Actions with Azure OIDC configured
w = WorkspaceClient(
host="https://adb-1234567890.azuredatabricks.net",
azure_client_id="your-azure-client-id",
auth_type="github-oidc-azure"
)
Azure DevOps OIDC¶
from databricks.sdk import WorkspaceClient
# In Azure DevOps with OIDC configured
# Note: SYSTEM_ACCESSTOKEN must be exposed as an environment variable
w = WorkspaceClient(
host="https://your-workspace.cloud.databricks.com",
client_id="your-databricks-oauth-client-id",
auth_type="azure-devops-oidc"
)
Google Cloud Credentials¶
from databricks.sdk import WorkspaceClient
w = WorkspaceClient(
host="https://your-workspace.gcp.databricks.com",
google_credentials="/path/to/service-account-key.json",
auth_type="google-credentials"
)
Google Cloud ID (Service Account Impersonation)¶
from databricks.sdk import WorkspaceClient
w = WorkspaceClient(
host="https://your-workspace.gcp.databricks.com",
google_service_account="your-service-account@project.iam.gserviceaccount.com",
auth_type="google-id"
)
Metadata Service¶
from databricks.sdk import WorkspaceClient
w = WorkspaceClient(
host="https://your-workspace.cloud.databricks.com",
metadata_service_url="http://localhost:8080/metadata",
auth_type="metadata-service"
)
Runtime (in Databricks Notebooks)¶
from databricks.sdk import WorkspaceClient
# No credentials needed when running in Databricks Runtime
# The runtime auth type is auto-detected
w = WorkspaceClient(auth_type="runtime")
Runtime OAuth (in Databricks Notebooks with scoped access)¶
from databricks.sdk import WorkspaceClient
# For fine-grained access control in notebooks
w = WorkspaceClient(
scopes="clusters sql",
auth_type="runtime-oauth"
)
Environment Variable OIDC¶
from databricks.sdk import WorkspaceClient
# OIDC token from DATABRICKS_OIDC_TOKEN environment variable
w = WorkspaceClient(
host="https://your-workspace.cloud.databricks.com",
auth_type="env-oidc"
)
File-based OIDC¶
from databricks.sdk import WorkspaceClient
# OIDC token from a file
w = WorkspaceClient(
host="https://your-workspace.cloud.databricks.com",
oidc_token_filepath="/path/to/oidc-token",
auth_type="file-oidc"
)
Model Serving Environment¶
from databricks.sdk import WorkspaceClient
# Auto-detected when running in Databricks Model Serving
w = WorkspaceClient(auth_type="model-serving")
Authentication Priority Order¶
When no auth_type is explicitly specified, the SDK attempts authentication methods in this order:
pat- Personal Access Tokenbasic- Username/Passwordmetadata-service- Metadata Service (if URL provided)oauth-m2m- OAuth Service Principalenv-oidc- Environment OIDC tokenfile-oidc- File-based OIDC tokengithub-oidc- GitHub OIDCazure-client-secret- Azure Service Principalgithub-oidc-azure- GitHub OIDC for Azureazure-cli- Azure CLIazure-devops-oidc- Azure DevOps OIDCexternal-browser- Browser-based OAuthdatabricks-cli- Databricks CLIruntime-oauth- Databricks Runtime OAuthruntime- Databricks Runtime nativegoogle-credentials- Google Cloud credentialsgoogle-id- Google Cloud IDmodel-serving- Model Serving environment
You can override this order by explicitly setting the auth_type parameter.
Notes¶
Auto-detected auth types (
runtime,runtime-oauth,model-serving): These are automatically detected based on environment variables and don’t require explicit configuration.Azure authentication: When using Azure-specific auth types, if
hostis not provided butazure_workspace_resource_idis, the SDK will automatically resolve the workspace URL.OIDC authentication: OIDC-based methods (
github-oidc,azure-devops-oidc,env-oidc,file-oidc) use token exchange to obtain Databricks tokens from external identity providers.Scopes: OAuth-based methods support the
scopesparameter for fine-grained access control (e.g.,scopes="clusters sql").
See Also¶
Authentication Overview - Default authentication flow and configuration
OAuth Documentation - OAuth-based authentication details
Databricks Authentication Documentation - Official Databricks authentication docs