<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic User OBO Token Forwarding between apps in Administration &amp; Architecture</title>
    <link>https://community.databricks.com/t5/administration-architecture/user-obo-token-forwarding-between-apps/m-p/134914#M4213</link>
    <description>&lt;P&gt;Can user OAuth tokens be forwarded between Databricks Apps for on-behalf-of (OBO) authorization?&lt;/P&gt;&lt;P&gt;I have two Databricks Apps deployed in the same workspace:&lt;BR /&gt;1. **UI App** (Streamlit) - configured with OAuth user authorization&lt;BR /&gt;2. **Middleware App** (FastAPI) - also configured with OAuth user authorization&lt;/P&gt;&lt;P&gt;Both apps have matching OAuth scopes configured in their `app.yaml`:&lt;/P&gt;&lt;P&gt;```yaml&lt;BR /&gt;# UI App&lt;BR /&gt;auth:&lt;BR /&gt;type: "user-authorization"&lt;BR /&gt;oauth:&lt;BR /&gt;scopes:&lt;BR /&gt;- sql&lt;BR /&gt;- iam.current-user.read&lt;BR /&gt;- iam.access-control.read&lt;BR /&gt;- catalog.tables.read&lt;BR /&gt;- catalog.schemas.read&lt;BR /&gt;- catalog.catalogs.read&lt;/P&gt;&lt;P&gt;# Middleware App (same scopes)&lt;BR /&gt;auth:&lt;BR /&gt;type: "user-authorization"&lt;BR /&gt;oauth:&lt;BR /&gt;scopes:&lt;BR /&gt;- sql&lt;BR /&gt;- iam.current-user.read&lt;BR /&gt;# ... (same as UI)&lt;BR /&gt;```&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;What I'm Trying to Achieve&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;When a user accesses the UI app and it makes HTTP requests to the middleware app, I want the middleware to:&lt;BR /&gt;1. Receive the **user's OAuth token** (not the UI app's service principal token)&lt;BR /&gt;2. Use that token to perform operations **on behalf of the user**&lt;BR /&gt;3. Query the user's groups via Databricks APIs (e.g., `WorkspaceClient.current_user.me()` or SCIM API)&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;What I've Tried&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;**Attempt 1: Authorization Header**&lt;BR /&gt;```python&lt;BR /&gt;# In UI app&lt;BR /&gt;token = st.context.headers.get("X-Forwarded-Access-Token")&lt;BR /&gt;response = requests.get(&lt;BR /&gt;middleware_url,&lt;BR /&gt;headers={"Authorization": f"Bearer {token}"}&lt;BR /&gt;)&lt;BR /&gt;```&lt;BR /&gt;**Result:** Middleware receives empty `Authorization` header (appears to be stripped by Databricks)&lt;/P&gt;&lt;P&gt;**Attempt 2: Custom Headers**&lt;BR /&gt;```python&lt;BR /&gt;headers={"X-User-Token": token}&lt;BR /&gt;```&lt;BR /&gt;**Result:** Custom headers are not forwarded between apps&lt;/P&gt;&lt;P&gt;**Attempt 3: OAuth Token Exchange**&lt;BR /&gt;```python&lt;BR /&gt;# Tried to exchange UI app token for middleware app token&lt;BR /&gt;```&lt;BR /&gt;**Result:** 403 error - "Client authentication failed: user 'middleware_client_id' is not a member of workspace"&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;Documentation I've Reviewed&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;1. **[Connect to API Databricks App](&lt;A href="https://docs.databricks.com/aws/en/dev-tools/databricks-apps/connect-local)**" target="_blank" rel="noopener"&gt;https://docs.databricks.com/aws/en/dev-tools/databricks-apps/connect-local)**&lt;/A&gt; states:&lt;BR /&gt;&amp;gt; "From other Databricks apps: the app handles authentication automatically using its assigned service principal."&lt;BR /&gt;&lt;BR /&gt;This seems to indicate service principals are used for app-to-app calls, not user tokens.&lt;/P&gt;&lt;P&gt;2. **[HTTP Headers Forwarded](&lt;A href="https://docs.databricks.com/aws/en/dev-tools/databricks-apps/http-headers)**" target="_blank" rel="noopener"&gt;https://docs.databricks.com/aws/en/dev-tools/databricks-apps/http-headers)**&lt;/A&gt; shows:&lt;BR /&gt;- &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; `X-Forwarded-Email`, `X-Forwarded-User`, `gap-auth` ARE forwarded&lt;BR /&gt;- &lt;span class="lia-unicode-emoji" title=":cross_mark:"&gt;❌&lt;/span&gt; `X-Forwarded-Access-Token` is NOT listed as forwarded between apps&lt;/P&gt;&lt;P&gt;3. The "Specify OAuth scopes" section discusses token generation for local/external access, but doesn't clarify app-to-app scenarios.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My Questions&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;1. **Is it possible to forward user OAuth tokens between Databricks Apps** for on-behalf-of (OBO) authorization?&lt;BR /&gt;&lt;BR /&gt;2. **If yes**, what is the correct method to:&lt;BR /&gt;- Forward the token from UI app to middleware app?&lt;BR /&gt;- Extract and use the token in the middleware app?&lt;BR /&gt;- Which header should be used?&lt;/P&gt;&lt;P&gt;3. **If no**, what is the recommended pattern for implementing **user-specific authorization** in a multi-app architecture where:&lt;BR /&gt;- UI app needs to call middleware app&lt;BR /&gt;- Middleware needs to know which user is making the request&lt;BR /&gt;- Middleware needs to enforce user-specific permissions (e.g., group-based access control)&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;Current Workaround&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I can extract the user's email from `X-Forwarded-Email` header and use the middleware's service principal to look up the user's groups, but this requires:&lt;BR /&gt;- Granting the middleware's service principal workspace admin permissions&lt;BR /&gt;- Operations are performed as the service principal, not as the actual user&lt;/P&gt;&lt;P&gt;Is there a better approach that preserves user context without requiring admin permissions?&lt;/P&gt;&lt;P&gt;---&lt;/P&gt;&lt;P&gt;## Environment&lt;BR /&gt;- **Databricks Runtime:** Apps (serverless)&lt;BR /&gt;- **Workspace Type:** Azure Databricks&lt;BR /&gt;- **App Framework:** Streamlit (UI), FastAPI (Middleware)&lt;BR /&gt;- **Authentication:** OAuth 2.0 User Authorization on both apps&lt;BR /&gt;- **Deployment:** Both apps deployed in same workspace&lt;/P&gt;&lt;P&gt;---&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Additional Context&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I've spent significant time investigating this and found that:&lt;BR /&gt;- Browser → App: User token IS forwarded via `X-Forwarded-Access-Token` &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt;&lt;BR /&gt;- App → App: User token appears NOT to be forwarded &lt;span class="lia-unicode-emoji" title=":cross_mark:"&gt;❌&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The documentation suggests using service principals for app-to-app calls, but I'm unclear if this is a limitation or if there's a configuration I'm missing to enable user token forwarding.&lt;/P&gt;&lt;P&gt;Any guidance on the correct architectural pattern for multi-app user authorization would be greatly appreciated!&lt;/P&gt;</description>
    <pubDate>Tue, 14 Oct 2025 19:48:55 GMT</pubDate>
    <dc:creator>ctgchris</dc:creator>
    <dc:date>2025-10-14T19:48:55Z</dc:date>
    <item>
      <title>User OBO Token Forwarding between apps</title>
      <link>https://community.databricks.com/t5/administration-architecture/user-obo-token-forwarding-between-apps/m-p/134914#M4213</link>
      <description>&lt;P&gt;Can user OAuth tokens be forwarded between Databricks Apps for on-behalf-of (OBO) authorization?&lt;/P&gt;&lt;P&gt;I have two Databricks Apps deployed in the same workspace:&lt;BR /&gt;1. **UI App** (Streamlit) - configured with OAuth user authorization&lt;BR /&gt;2. **Middleware App** (FastAPI) - also configured with OAuth user authorization&lt;/P&gt;&lt;P&gt;Both apps have matching OAuth scopes configured in their `app.yaml`:&lt;/P&gt;&lt;P&gt;```yaml&lt;BR /&gt;# UI App&lt;BR /&gt;auth:&lt;BR /&gt;type: "user-authorization"&lt;BR /&gt;oauth:&lt;BR /&gt;scopes:&lt;BR /&gt;- sql&lt;BR /&gt;- iam.current-user.read&lt;BR /&gt;- iam.access-control.read&lt;BR /&gt;- catalog.tables.read&lt;BR /&gt;- catalog.schemas.read&lt;BR /&gt;- catalog.catalogs.read&lt;/P&gt;&lt;P&gt;# Middleware App (same scopes)&lt;BR /&gt;auth:&lt;BR /&gt;type: "user-authorization"&lt;BR /&gt;oauth:&lt;BR /&gt;scopes:&lt;BR /&gt;- sql&lt;BR /&gt;- iam.current-user.read&lt;BR /&gt;# ... (same as UI)&lt;BR /&gt;```&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;What I'm Trying to Achieve&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;When a user accesses the UI app and it makes HTTP requests to the middleware app, I want the middleware to:&lt;BR /&gt;1. Receive the **user's OAuth token** (not the UI app's service principal token)&lt;BR /&gt;2. Use that token to perform operations **on behalf of the user**&lt;BR /&gt;3. Query the user's groups via Databricks APIs (e.g., `WorkspaceClient.current_user.me()` or SCIM API)&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;What I've Tried&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;**Attempt 1: Authorization Header**&lt;BR /&gt;```python&lt;BR /&gt;# In UI app&lt;BR /&gt;token = st.context.headers.get("X-Forwarded-Access-Token")&lt;BR /&gt;response = requests.get(&lt;BR /&gt;middleware_url,&lt;BR /&gt;headers={"Authorization": f"Bearer {token}"}&lt;BR /&gt;)&lt;BR /&gt;```&lt;BR /&gt;**Result:** Middleware receives empty `Authorization` header (appears to be stripped by Databricks)&lt;/P&gt;&lt;P&gt;**Attempt 2: Custom Headers**&lt;BR /&gt;```python&lt;BR /&gt;headers={"X-User-Token": token}&lt;BR /&gt;```&lt;BR /&gt;**Result:** Custom headers are not forwarded between apps&lt;/P&gt;&lt;P&gt;**Attempt 3: OAuth Token Exchange**&lt;BR /&gt;```python&lt;BR /&gt;# Tried to exchange UI app token for middleware app token&lt;BR /&gt;```&lt;BR /&gt;**Result:** 403 error - "Client authentication failed: user 'middleware_client_id' is not a member of workspace"&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;Documentation I've Reviewed&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;1. **[Connect to API Databricks App](&lt;A href="https://docs.databricks.com/aws/en/dev-tools/databricks-apps/connect-local)**" target="_blank" rel="noopener"&gt;https://docs.databricks.com/aws/en/dev-tools/databricks-apps/connect-local)**&lt;/A&gt; states:&lt;BR /&gt;&amp;gt; "From other Databricks apps: the app handles authentication automatically using its assigned service principal."&lt;BR /&gt;&lt;BR /&gt;This seems to indicate service principals are used for app-to-app calls, not user tokens.&lt;/P&gt;&lt;P&gt;2. **[HTTP Headers Forwarded](&lt;A href="https://docs.databricks.com/aws/en/dev-tools/databricks-apps/http-headers)**" target="_blank" rel="noopener"&gt;https://docs.databricks.com/aws/en/dev-tools/databricks-apps/http-headers)**&lt;/A&gt; shows:&lt;BR /&gt;- &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt; `X-Forwarded-Email`, `X-Forwarded-User`, `gap-auth` ARE forwarded&lt;BR /&gt;- &lt;span class="lia-unicode-emoji" title=":cross_mark:"&gt;❌&lt;/span&gt; `X-Forwarded-Access-Token` is NOT listed as forwarded between apps&lt;/P&gt;&lt;P&gt;3. The "Specify OAuth scopes" section discusses token generation for local/external access, but doesn't clarify app-to-app scenarios.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My Questions&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;1. **Is it possible to forward user OAuth tokens between Databricks Apps** for on-behalf-of (OBO) authorization?&lt;BR /&gt;&lt;BR /&gt;2. **If yes**, what is the correct method to:&lt;BR /&gt;- Forward the token from UI app to middleware app?&lt;BR /&gt;- Extract and use the token in the middleware app?&lt;BR /&gt;- Which header should be used?&lt;/P&gt;&lt;P&gt;3. **If no**, what is the recommended pattern for implementing **user-specific authorization** in a multi-app architecture where:&lt;BR /&gt;- UI app needs to call middleware app&lt;BR /&gt;- Middleware needs to know which user is making the request&lt;BR /&gt;- Middleware needs to enforce user-specific permissions (e.g., group-based access control)&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;Current Workaround&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I can extract the user's email from `X-Forwarded-Email` header and use the middleware's service principal to look up the user's groups, but this requires:&lt;BR /&gt;- Granting the middleware's service principal workspace admin permissions&lt;BR /&gt;- Operations are performed as the service principal, not as the actual user&lt;/P&gt;&lt;P&gt;Is there a better approach that preserves user context without requiring admin permissions?&lt;/P&gt;&lt;P&gt;---&lt;/P&gt;&lt;P&gt;## Environment&lt;BR /&gt;- **Databricks Runtime:** Apps (serverless)&lt;BR /&gt;- **Workspace Type:** Azure Databricks&lt;BR /&gt;- **App Framework:** Streamlit (UI), FastAPI (Middleware)&lt;BR /&gt;- **Authentication:** OAuth 2.0 User Authorization on both apps&lt;BR /&gt;- **Deployment:** Both apps deployed in same workspace&lt;/P&gt;&lt;P&gt;---&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Additional Context&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I've spent significant time investigating this and found that:&lt;BR /&gt;- Browser → App: User token IS forwarded via `X-Forwarded-Access-Token` &lt;span class="lia-unicode-emoji" title=":white_heavy_check_mark:"&gt;✅&lt;/span&gt;&lt;BR /&gt;- App → App: User token appears NOT to be forwarded &lt;span class="lia-unicode-emoji" title=":cross_mark:"&gt;❌&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The documentation suggests using service principals for app-to-app calls, but I'm unclear if this is a limitation or if there's a configuration I'm missing to enable user token forwarding.&lt;/P&gt;&lt;P&gt;Any guidance on the correct architectural pattern for multi-app user authorization would be greatly appreciated!&lt;/P&gt;</description>
      <pubDate>Tue, 14 Oct 2025 19:48:55 GMT</pubDate>
      <guid>https://community.databricks.com/t5/administration-architecture/user-obo-token-forwarding-between-apps/m-p/134914#M4213</guid>
      <dc:creator>ctgchris</dc:creator>
      <dc:date>2025-10-14T19:48:55Z</dc:date>
    </item>
    <item>
      <title>Re: User OBO Token Forwarding between apps</title>
      <link>https://community.databricks.com/t5/administration-architecture/user-obo-token-forwarding-between-apps/m-p/134979#M4218</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/191644"&gt;@ctgchris&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just pushing this issue for visibility to others. Someone from databricks can come up with a solution.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Oct 2025 09:33:09 GMT</pubDate>
      <guid>https://community.databricks.com/t5/administration-architecture/user-obo-token-forwarding-between-apps/m-p/134979#M4218</guid>
      <dc:creator>Khaja_Zaffer</dc:creator>
      <dc:date>2025-10-15T09:33:09Z</dc:date>
    </item>
  </channel>
</rss>

