Skip to content
Back to skills

Databricks Apps Cookie Auth

ASecurity

Guide for authenticating with Databricks Apps using cookie-based auth when OAuth/PAT tokens don't work. Use when connecting to Databricks Apps with User Authorization enabled.

  • 666 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added February 8, 2026
securitypythonnodetestingapisecurity

Works with

  • cli
  • api
  • mcp

Security analysis

A100/100

Scanned February 12, 2026

npx -y skills add majiayu000/claude-skill-registry --skill databricks-apps-cookie-auth --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Databricks Apps Cookie Auth?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Databricks Apps Cookie Auth
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/majiayu000-databricks-apps-cookie-auth/badge)](https://www.skillsdirectory.com/skills/majiayu000-databricks-apps-cookie-auth)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: databricks-apps-cookie-auth
description: Guide for authenticating with Databricks Apps using cookie-based auth when OAuth/PAT tokens don't work. Use when connecting to Databricks Apps with User Authorization enabled.
---

# 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.

## Solution: Cookie-Based Authentication

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

### Cookie Format

```
__Host-databricksapps=<encrypted_session_data>|<timestamp>|<signature>
```

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

### Code Example

```python
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

### Related Auth Types

| Auth Type | Use Case | Connection Phase | Tool Execution Phase |
|-----------|----------|------------------|---------------------|
| BEARER | Static tokens, PATs | Headers | Headers |
| API_KEY | API keys | Headers | Headers |
| OAUTH2_USER | HITL OAuth | Deferred | HITL flow |
| COOKIE (new) | Databricks Apps | Cookie header | Cookie header |

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.