Bird CLI (@steipete/bird) needs auth_token + ct0 cookies to authenticate with X's GraphQL API. The built-in sweet-cookie library reads Chrome's SQLite cookie DB, but often fails on macOS due to Keychain access permissions.
Instead of reading the cookie SQLite file, connect to Chrome's DevTools Protocol and ask the running browser for its cookies directly. No Keychain access needed.
-
Chrome running with remote debugging:
# Launch Chrome with CDP enabled (add to alias) open -a "Google Chrome" --args --remote-debugging-port=9222 # Or if Chrome is already running, check if CDP is available: curl -s http://localhost:9222/json/version
-
Logged into x.com in Chrome
-
Python 3 + websockets:
pip install websockets
Chrome (CDP port 9222)
├── GET /json → List all open tabs
├── Find tab with x.com URL → Get WebSocket debugger URL
└── WebSocket connection
├── Network.enable → Activate network domain
└── Network.getCookies → Extract auth_token + ct0
└── {urls: ["https://x.com"]}
- Discovery:
GET http://localhost:9222/jsonreturns JSON array of all tabs - Filter: Find any tab with
x.comortwitter.comin the URL - Connect: Open WebSocket to that tab's
webSocketDebuggerUrl - Extract: Call
Network.getCookieswith x.com URLs - Parse: Pull
auth_tokenandct0from the cookie array
python3 extract_x_cookies_cdp.py
python3 extract_x_cookies_cdp.py --export-env # shell export lines
python3 extract_x_cookies_cdp.py --json # JSON output
python3 extract_x_cookies_cdp.py --bird-config # write ~/.config/bird/config.json5# Method 1: CLI flags
bird whoami --auth-token "TOKEN" --ct0 "CT0"
# Method 2: Env vars
export AUTH_TOKEN="TOKEN"
export CT0="CT0"
bird whoami
# Method 3: Inline
eval $(python3 extract_x_cookies_cdp.py --export-env) && bird whoami| Method | Pros | Cons |
|---|---|---|
| sweet-cookie (SQLite) | No Chrome needed running | Keychain permission errors on macOS, browser must be closed |
| CDP (WebSocket) | Works while Chrome is running, no Keychain issues | Chrome must be running with --remote-debugging-port |
- CDP port is localhost only by default — no remote access
- Tokens are session cookies — they rotate when you log out/in
- Don't commit tokens to version control
- The
auth_tokencookie is your full session — treat it like a password