How to Configure Twitter X Cookies for Agent Reach

Agent Reach requires the auth_token and ct0 cookies from X (Twitter), which you can supply manually via the CLI or extract automatically from Chrome, Firefox, Edge, Brave, or Opera.

To use X (formerly Twitter) inside the Panniantong/Agent-Reach framework, you must configure Twitter X cookies for Agent Reach so the platform can authenticate read and search requests. The CLI persists these credentials in ~/.agent-reach/config.yaml and synchronizes them to downstream helper tools.

Required Cookies to Configure Twitter X

Agent Reach relies on exactly two X authentication cookies:

  • auth_token – mapped internally to the key twitter_auth_token
  • ct0 – mapped internally to the key twitter_ct0

These values are defined as required configuration keys in agent_reach/config.py (lines 22–25). When the CLI runs, it reads those keys and optionally propagates them to legacy utilities that also talk to X.

Where Agent Reach Stores and Syncs Twitter X Cookies

After you run the configuration command, Agent Reach writes the tokens to several destinations depending on the tools installed:

  • Agent Reach config – persisted in ~/.agent-reach/config.yaml via Config.set("twitter_auth_token", …) as implemented in agent_reach/config.py.
  • twitter-cli environment – injected as TWITTER_AUTH_TOKEN and TWITTER_CT0 process environment variables just before the CLI runs twitter status. This logic lives in _cmd_configure inside agent_reach/cli.py (lines 65–78).
  • xfetch legacy – agent_reach.cookie_extract._sync_xfetch_session copies the values to ~/.config/xfetch/session.json.
  • bird-cli – agent_reach.cookie_extract._sync_bird_env writes a sourceable file at ~/.config/bird/credentials.env containing AUTH_TOKEN=… and CT0=….

The TwitterChannel class in agent_reach/channels/twitter.py checks for the presence of twitter-cli or bird and reports whether credentials are available.

Manually Configure Twitter X Cookies Through the CLI

The most common way to configure Twitter X cookies for Agent Reach is to pass them directly to the CLI. The parser that handles this input is _parse_twitter_cookie_input in agent_reach/cli.py (lines 24–42).

You have two syntax options:


# Option A – pass the two cookies as separate arguments

agent-reach configure twitter-cookies AUTH_TOKEN_VALUE CT0_VALUE

# Option B – pass a raw cookie header string

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

After the command stores the values, the CLI validates them by spawning twitter status via subprocess.run and checking for "ok: true" in the output. A successful run prints:

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

Automatically Extract Twitter X Cookies from Your Browser

If you are already logged into X in a supported browser, you can let Agent Reach extract the cookies automatically. Supported browsers include Chrome, Firefox, Edge, Brave, and Opera.

Run the following command:

agent-reach configure --from-browser chrome

Under the hood, configure_from_browser in agent_reach/cookie_extract.py (lines 18–35) iterates over supported platforms using either rookiepy or browser-cookie3. When it finds X cookies, it writes them to the config and triggers legacy syncs:


# Excerpt from agent_reach/cookie_extract.py

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

Successful extraction produces output similar to:

Extracting cookies from chrome...

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

To confirm that Agent Reach saved the cookies correctly, inspect the local YAML file:

cat ~/.agent-reach/config.yaml

You should see entries like:

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

The Config.to_dict() method masks sensitive fields when the CLI prints summaries, so the raw file is the best way to audit the persisted values.

Summary

  • Agent Reach requires exactly two cookies to talk to X: auth_token and ct0.
  • Credentials are stored in ~/.agent-reach/config.yaml under the keys twitter_auth_token and twitter_ct0.
  • You can manually supply cookies via agent-reach configure twitter-cookies using either separate arguments or a raw header string.
  • You can automatically extract cookies from Chrome, Firefox, Edge, Brave, or Opera with agent-reach configure --from-browser <name>.
  • The CLI validates connectivity by running twitter status and checking for "ok: true".
  • Internally, agent_reach/cli.py parses input, agent_reach/cookie_extract.py handles browser extraction, and agent_reach/config.py manages persistence.

Frequently Asked Questions

What cookies are required to configure Twitter X for Agent Reach?

Agent Reach needs auth_token and ct0. These are the two session cookies X uses to maintain an authenticated session. They are mapped to the internal config keys twitter_auth_token and twitter_ct0.

Yes. The _parse_twitter_cookie_input helper in agent_reach/cli.py (lines 24–42) accepts a raw header string such as "auth_token=AAA; ct0=BBB" and extracts the relevant values automatically.

Agent Reach supports automatic extraction from Chrome, Firefox, Edge, Brave, and Opera. The configure_from_browser function in agent_reach/cookie_extract.py uses either rookiepy or browser-cookie3 to read the browser’s cookie store.

How does Agent Reach verify that my Twitter X cookies are valid?

The CLI runs a validation check via _cmd_configure in agent_reach/cli.py (lines 65–78). It spawns twitter status through subprocess.run and inspects the output for the string "ok: true". If the check fails, the CLI prints an error so you can re-run the configuration step.

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 →