スキル一覧に戻る
hurtener

databricks-apps-cookie-auth

by hurtener

A tiny, dependency-light Python library (penguiflow) that lets define typed, concurrent agent pipelines.

1🍴 1📅 2026年1月22日
GitHubで見るManusで実行

SKILL.md


Databricks Apps Cookie Authentication

Problem Solved

Databricks Apps that require browser-based OAuth cannot be accessed with service principals or PATs when the app is configured for "User Authorization" only. The app always redirects to OAuth login regardless of Bearer tokens sent.

After a user completes browser OAuth login, Databricks Apps set a session cookie __Host-databricksapps that can be captured and reused for API access.

How It Works

  1. User logs into the Databricks App via browser
  2. Browser receives __Host-databricksapps cookie after successful OAuth
  3. Cookie is captured from browser DevTools (Application > Cookies)
  4. Cookie is passed as header in MCP client requests
__Host-databricksapps=<encrypted_session_data>|<timestamp>|<signature>

The timestamp indicates expiry - cookies typically expire after a session timeout.

Code Example

from mcp.client.session import ClientSession
from mcp.client.streamable_http import streamablehttp_client
from datetime import timedelta

async def connect_with_cookie(url: str, cookie_value: str):
    http_context = streamablehttp_client(
        url,
        headers={'Cookie': f'__Host-databricksapps={cookie_value}'}
    )
    read, write, _ = await http_context.__aenter__()

    session = ClientSession(read, write, read_timeout_seconds=timedelta(seconds=60))
    await session.__aenter__()
    await session.initialize()

    tools = await session.list_tools()
    return tools

When to Use This

  • Databricks Apps with "User Authorization" enabled but no service principal access
  • Apps that redirect to OAuth regardless of Bearer tokens
  • Testing/development scenarios where HITL OAuth isn't implemented yet

Limitations

  1. Session Expiry: Cookies expire, requiring periodic browser re-login
  2. User-Specific: Cookie is tied to the user who logged in
  3. Security: Cookie contains sensitive session data - handle securely

Relevant Files

  • penguiflow/tools/node.py - ToolNode implementation
  • penguiflow/tools/config.py - AuthType enum
  • test_generation/reporting-agent/src/reporting_agent/external_tools.py - Example usage
Auth TypeUse CaseConnection PhaseTool Execution Phase
BEARERStatic tokens, PATsHeadersHeaders
API_KEYAPI keysHeadersHeaders
OAUTH2_USERHITL OAuthDeferredHITL flow
COOKIE (new)Databricks AppsCookie headerCookie header

スコア

総合スコア

70/100

リポジトリの品質指標に基づく評価

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

+10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

レビュー

💬

レビュー機能は近日公開予定です