How to Configure Twitter Cookies Using the Agent Reach CLI

To configure Twitter cookies for Agent Reach, use the agent-reach configure twitter-cookies command with your auth_token and ct0 values, or use the --from-browser flag to extract them automatically from Chrome, Firefox, Edge, Brave, or Opera.

The Panniantong/Agent-Reach repository provides a CLI tool that manages authentication for X (formerly Twitter) by storing the auth_token and ct0 cookies in your local configuration file. This guide explains how to configure these credentials using the Agent Reach CLI, covering both manual entry and automatic extraction from your browser.

Required Twitter Authentication Tokens

Agent Reach requires two specific authentication cookies from X (Twitter): auth_token and ct0. These tokens authenticate your requests and allow the tool to interact with the platform on your behalf.

These values are persisted in ~/.agent-reach/config.yaml under the keys twitter_auth_token and twitter_ct0. When the CLI runs, it reads these keys and optionally synchronizes them to helper tools including twitter-cli, xfetch, and bird-cli.

Method 1: Manual Configuration

The most common approach is to provide the cookies directly via the command line. The CLI accepts input in two formats through the _parse_twitter_cookie_input function in agent_reach/cli.py.

Option A: Separate Arguments

Pass the auth_token and ct0 values as distinct arguments:

agent-reach configure twitter-cookies AUTH_TOKEN_VALUE CT0_VALUE

Paste the raw cookie string copied directly from your browser's developer tools:

agent-reach configure twitter-cookies "auth_token=AAA; ct0=BBB; other=ignore"

The parser in agent_reach/cli.py (lines 24-42) extracts the relevant values while ignoring unrelated cookies.

Validation Process

After storing the credentials, the CLI validates them by invoking twitter status via subprocess.run and checking for "ok: true" in the output. Successful configuration outputs:


✅ Twitter cookies configured!
Testing Twitter access... ✅ Twitter access works!

If validation fails, the CLI displays an error message and you must re-run the configuration step.

Method 2: Automatic Browser Extraction

Agent Reach can automatically extract cookies from supported browsers including Chrome, Firefox, Edge, Brave, and Opera. This method uses the configure_from_browser function in agent_reach/cookie_extract.py.

Run the following command:

agent-reach configure --from-browser chrome

Under the hood, the tool uses rookiepy or browser-cookie3 to extract cookies:


# Excerpt from agent_reach/cookie_extract.py (lines 20-35)

if "twitter" in extracted:
    tc = extracted["twitter"]
    if "auth_token" in tc and "ct0" in tc:
        config.set("twitter_auth_token", tc["auth_token"])
        config.set("twitter_ct0", tc["ct0"])
        _sync_xfetch_session(tc["auth_token"], tc["ct0"])   # legacy sync

Upon success, you'll see confirmation for each platform found:


Extracting cookies from chrome...

✅ Twitter/X: auth_token + ct0
✅ XiaoHongShu: 12 cookies
...
✅ Cookies configured! Run `agent-reach doctor` to see updated status.

Credential Storage and Synchronization

Agent Reach synchronizes your Twitter cookies to multiple locations for compatibility with different tooling:

  • Agent Reach config: ~/.agent-reach/config.yaml — persistent storage via Config.set() as defined in agent_reach/config.py
  • twitter-cli environment: TWITTER_AUTH_TOKEN and TWITTER_CT0 environment variables injected by _cmd_configure in agent_reach/cli.py (lines 65-78)
  • xfetch legacy: ~/.config/xfetch/session.json — updated via _sync_xfetch_session
  • bird-cli: ~/.config/bird/credentials.env — written as AUTH_TOKEN=... and CT0=... via _sync_bird_env

Verifying Your Configuration

To confirm your cookies are stored correctly, inspect the configuration file:

cat ~/.agent-reach/config.yaml

You should see the masked values:

twitter_auth_token: "AAA..."
twitter_ct0: "BBB..."

Note that Config.to_dict() masks sensitive fields when displaying summaries in the CLI output.

Summary

  • Agent Reach requires auth_token and ct0 from X (Twitter) to function.
  • Store credentials manually using agent-reach configure twitter-cookies with either separate values or a raw cookie header.
  • Extract cookies automatically using agent-reach configure --from-browser <browser> supported by agent_reach/cookie_extract.py.
  • The CLI validates tokens by running twitter status and checking for "ok: true" before confirming success.
  • Credentials sync to ~/.agent-reach/config.yaml and legacy paths for twitter-cli, xfetch, and bird-cli compatibility.

Frequently Asked Questions

What are the auth_token and ct0 cookies?

The auth_token and ct0 cookies are authentication tokens issued by X (Twitter) when you log in. According to the Agent Reach source code in agent_reach/config.py, these are stored as twitter_auth_token and twitter_ct0 respectively, and they allow the CLI to make authenticated requests on your behalf without requiring your password.

Can I extract cookies from any web browser?

Agent Reach supports automatic extraction from Chrome, Firefox, Edge, Brave, and Opera. The configure_from_browser function in agent_reach/cookie_extract.py iterates over these supported platforms using either rookiepy or browser-cookie3 libraries to locate and extract the cookie values from your browser's local storage.

How do I know if my Twitter cookies are valid?

The CLI automatically validates cookies immediately after configuration. As implemented in _cmd_configure within agent_reach/cli.py, the tool runs twitter status via subprocess.run and verifies the output contains "ok: true". If validation fails, the CLI displays an error message and you must re-run the configuration step with correct credentials.

Where are my Twitter cookies stored locally?

Your cookies are primarily stored in ~/.agent-reach/config.yaml under the keys twitter_auth_token and twitter_ct0. Additionally, Agent Reach synchronizes these values to helper tools: ~/.config/xfetch/session.json for legacy xfetch compatibility, and ~/.config/bird/credentials.env for bird-cli, as handled by the _sync_xfetch_session and _sync_bird_env functions.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →