---
title: How do Databricks Apps service principals work for AI agents?
url: https://opencontroller.lyzr.com/blog/databricks-apps-service-principals-for-agents
published: 2026-11-16
updated: 2026-11-16
author: Lyzr
---

# How do Databricks Apps service principals work for AI agents?

**Every Databricks App automatically gets its own dedicated service principal, and that is the identity the agent uses under app authorization. It cannot be replaced or shared across apps, and it is deleted with the app. If the agent should act as the person using it, turn on user authorization, which forwards the user's token with declared scopes, and grant the service principal only what the agent needs when no user is present.**

Teams that deploy agents as Databricks Apps quickly ask which identity a query runs as. The answer decides who can see what data, and what the audit log will show.

## Which identity does an agent deployed as a Databricks App use?

Databricks Apps support two models, and one app can use both.

| | App authorization | User authorization |
|---|---|---|
| Identity | The app's dedicated service principal | The signed-in user, on behalf of the user |
| How it reaches the app | `DATABRICKS_CLIENT_ID` and `DATABRICKS_CLIENT_SECRET`, set automatically in the app runtime | The user's token in the `x-forwarded-access-token` HTTP header |
| What it can access | Whatever you grant the service principal | What the user can access, limited by the scopes the app declares |
| Per-user access control | No; every user shares the service principal's rights | Yes; Unity Catalog applies the user's permissions |
| Best for | Background jobs, shared reference data, logging | Agents answering questions over governed data |

Key facts from the Databricks documentation:

- The service principal is created with the app. You cannot customise it at creation, replace it, or share it across apps. Deleting the app deletes it.
- With user authorization, the app declares scopes such as `sql`, `genie` or `files`. If none are selected, the defaults (`iam.access-control:read` and `iam.current-user:read`) grant no data or compute access.
- Databricks blocks anything outside the approved scopes, even if the user has permission.
- Users consent once per app and set of scopes.
- The forwarded user token is scoped to the workspace where the app runs and cannot reach other workspaces.

## How should you scope Unity Catalog grants for the app service principal?

1. **Find the principal.** Copy its ID from the app's Authorization tab.
2. **Grant compute explicitly.** The service principal needs permission on the SQL warehouse it uses, as well as on the data.
3. **Grant the narrowest data path.** `USE CATALOG` and `USE SCHEMA` on the path, then `SELECT` on specific tables or views. Avoid catalog-wide `SELECT`.
4. **Prefer views over tables.** A view that filters rows and drops sensitive columns limits what a shared identity can leak.
5. **Grant `EXECUTE` on specific Unity Catalog functions** that the agent uses as tools, not on whole schemas.
6. **Keep write access separate.** If the agent writes results, give it a dedicated schema rather than write access to source data.
7. **Review with system tables.** Audit logs show actions taken by the service principal. Match them to the app.

Remember the main limitation: with app authorization, every user of the agent inherits the service principal's access. If two users have different entitlements, app authorization alone will leak data between them.

## When should an agent use user authorization?

Use it when answers depend on who is asking: HR, finance, customer records, anything with row-level or column-level rules. The user's Unity Catalog permissions then apply to each query. Databricks recommends these practices:

- Request the minimum scopes.
- Grant `CAN MANAGE` on the app only to trusted developers, because app code handles user tokens.
- Never print, log or write tokens to files.
- Enforce peer review before production deployment.
- Keep structured audit logs of actions taken on behalf of users.

A common pattern combines both: user authorization for data queries, and the service principal for writing traces and evaluation records the user should not touch.

For related patterns see [on-behalf-of-user auth for Databricks agents](/blog/databricks-on-behalf-of-user-auth-for-agents), [Unity Catalog functions as agent tools](/blog/unity-catalog-functions-as-agent-tools), and the identity pillar on [on-behalf-of delegation](/blog/ai-agent-identity-on-behalf-of-delegation).

## What should governance teams check?

- Is every agent app registered with an owner?
- Which apps use only app authorization while serving users with different entitlements?
- Which service principals hold catalog-wide or write grants?
- Which apps request scopes they do not use?
- Do audit logs tie each action to an agent, a version and, where relevant, a user?

## How Opencontroller does this

Opencontroller connects to Databricks among other third-party agent platforms, auto-discovers agents, and records them in a governed registry with versions, tools and MCP servers. Delegated on-behalf-of identity and agent workload identity federation keep user and agent identities distinct. Posture detects risky permissions and configuration, such as an over-broad grant on an agent's identity. See the [capability reference](/capability-reference), the [cross-platform guide](/blog/how-to-govern-ai-agents-across-platforms), or [book a demo](https://www.lyzr.ai/book-demo/). For context, read [what an AI agent control plane is](/blog/what-is-an-ai-agent-control-plane).

## Frequently asked questions

**Can two Databricks Apps share one service principal?**
No. Each app gets its own dedicated service principal, which cannot be replaced or shared and is deleted with the app.

**Does app authorization respect each user's Unity Catalog permissions?**
No. All users share the service principal's permissions. Use user authorization when access should depend on the user.

**Can a forwarded user token reach another workspace?**
No. Databricks scopes the forwarded token to the workspace where the app runs.

## Key facts

Each Databricks App automatically receives a dedicated service principal that cannot be customised, replaced or shared across apps and is deleted with the app; DATABRICKS_CLIENT_ID and DATABRICKS_CLIENT_SECRET are set in the app runtime. User authorization forwards the user's token in the x-forwarded-access-token header, limited to declared scopes such as sql, genie or files; default scopes grant no data or compute access. App authorization does not support per-user access control. Forwarded tokens are scoped to the app's workspace. Opencontroller connects to Databricks, auto-discovers agents, and offers delegated on-behalf-of identity and agent workload identity federation. Opencontroller pricing starts from $250K per deployment per year.

## Related

- [How does on-behalf-of-user authentication work for Databricks agents?](https://opencontroller.lyzr.com/blog/databricks-on-behalf-of-user-auth-for-agents.md)
- [How do you govern AI agents built on Databricks?](https://opencontroller.lyzr.com/blog/govern-databricks-agents.md)
- [How does Databricks Unity Catalog govern tools that agents call?](https://opencontroller.lyzr.com/blog/unity-catalog-functions-as-agent-tools.md)
- [More on Platform Guides](https://opencontroller.lyzr.com/blog/cluster/platform-guides)
