Skip to content

feat: browser SSO via Chrome cookie reading (browser-cookie3)#342

Merged
manojbajaj95 merged 3 commits into
mainfrom
feature/browser-sso-cookie3
May 27, 2026
Merged

feat: browser SSO via Chrome cookie reading (browser-cookie3)#342
manojbajaj95 merged 3 commits into
mainfrom
feature/browser-sso-cookie3

Conversation

@manojbajaj95
Copy link
Copy Markdown
Collaborator

Summary

  • Adds a new browser auth type enabling authenticated access to sites like X/Twitter and LinkedIn that use browser session cookies rather than OAuth or API keys
  • Uses browser-cookie3 to read Chrome's on-disk SQLite cookie database directly (macOS Keychain / Linux GNOME Keyring / Windows DPAPI) — no Playwright, no separate Chrome profile
  • All core logic lives in auth/ per codebase constraint; server and CLI changes are registration-only (~35 and 8 lines respectively)

How it works

  1. authsome login x-browser — daemon creates a browser session, CLI reads Chrome cookies immediately; if no valid session found, opens x.com/login in the user's browser and polls the cookie DB every 4s
  2. Valid cookies stored encrypted in the vault under ConnectionRecord.credentials
  3. authsome run -- curl https://x.com/... — proxy injects Cookie: header plus any provider-specific headers (e.g. x-csrf-token from ct0 for X, csrf-token from JSESSIONID for LinkedIn)

New files

File Purpose
auth/browser_cookies.py Chrome SQLite reader; LinkedIn JSESSIONID normalizer
auth/flows/browser.py BrowserFlow (daemon) + static run_login() (CLI)
auth/bundled_providers/x-browser.json X/Twitter provider
auth/bundled_providers/linkedin-browser.json LinkedIn provider
tests/auth/test_browser_{cookies,flow,service}.py 30 unit tests

Test plan

  • uv run pytest tests/auth/test_browser_cookies.py tests/auth/test_browser_flow.py tests/auth/test_browser_service.py -v — 30 tests pass
  • uv run pytest -p no:xdist — 362 tests pass, no regressions
  • uv run ruff check src/ tests/ — clean
  • uv run ty check src/ — clean
  • Manual: authsome login x-browser (requires Chrome logged into X), authsome run -- curl -s "https://api.twitter.com/2/users/me"

🤖 Generated with Claude Code

manojbajaj95 and others added 3 commits May 27, 2026 12:27
Enables authenticated access to sites like X/Twitter and LinkedIn that
use browser session cookies rather than OAuth or API keys.

Core logic lives entirely in auth/ — BrowserFlow.run_login() reads
Chrome's on-disk SQLite cookie database via browser-cookie3 (macOS
Keychain / Linux GNOME Keyring / Windows DPAPI), opens the site in the
user's default browser if no valid session exists, then polls until the
required auth cookies appear.  No separate Chrome profile, no Playwright.

- auth/browser_cookies.py: read_chrome_cookies(), cookies_are_valid(),
  normalize_jsessionid() with lazy browser-cookie3 import
- auth/flows/browser.py: BrowserFlow (begin/resume/refresh) + static
  run_login() for CLI use
- auth/models/: AuthType.BROWSER, FlowType.BROWSER, BrowserConfig,
  ExtractRule, ConnectionRecord.credentials field
- server/: register flow, header rendering, export branch, BrowserAction
  schema, _session_response wiring (~35 lines total)
- cli/main.py: 8-line elif block calling BrowserFlow.run_login()
- Bundled providers: x-browser, linkedin-browser
- 30 new tests in tests/auth/

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Entire-Checkpoint: 3753e27e5941
@manojbajaj95 manojbajaj95 merged commit 7607600 into main May 27, 2026
4 checks passed
@manojbajaj95 manojbajaj95 deleted the feature/browser-sso-cookie3 branch May 27, 2026 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants