Skip to main content
Use Databricks workload identity federation to exchange a Trigger.dev OIDC token for a Databricks OAuth token. Your tasks run queries as a service principal with no DATABRICKS_TOKEN or DATABRICKS_CLIENT_SECRET stored anywhere. Follow the OIDC prerequisites, then go to the OIDC page for your environment and copy the issuer URL and subject.

Configure Databricks

Create a service principal (or reuse one), grant it access to the warehouse and data your task uses, and add a federation policy with the Databricks CLI. Replace the numeric service principal ID, your organization slug, account ID, and the subject:
Use the complete subject copied from the dashboard. The audience shown is Databricks’ default; any value works if the task requests the same one. A service principal holds at most 20 federation policies.

Query Databricks in your task

Exchange the OIDC token at your workspace’s token endpoint, then pass the access token to the SQL driver:
/trigger/query-databricks.ts
client_id is the service principal’s UUID (its application ID), not the numeric ID used in the CLI command.
The Databricks access token expires when the OIDC token it was exchanged for does, which is five minutes for Trigger.dev tokens, and there’s no refresh token. For longer work, request a new OIDC token and exchange it again.

Remove the old credential

Once runs in every deployed environment authenticate this way, delete DATABRICKS_TOKEN and DATABRICKS_CLIENT_SECRET from those environments on the Environment Variables page, then revoke the token or OAuth secret in Databricks. Local Development runs can’t mint OIDC tokens. Use your own Databricks login there when ctx.environment.type === "DEVELOPMENT".