# How to Configure Twitter Authentication Cookies for Agent-Reach: A Complete Guide

> Learn how to configure Twitter authentication cookies for Agent-Reach. This complete guide covers manual CLI entry and automatic extraction from popular browsers for seamless API access.

- Repository: [Pnant/Agent-Reach](https://github.com/Panniantong/Agent-Reach)
- Tags: how-to-guide
- Published: 2026-07-19

---

**Agent-Reach reads Twitter authentication data from `~/.agent-reach/config.yaml` and supports both manual CLI entry and automatic extraction from Chrome, Firefox, Edge, Brave, or Opera to authenticate with the Twitter API.**

Agent-Reach is an open-source automation framework by Panniantong that enables agent-based interactions through multiple channels, including Twitter. To post or retrieve data via the **TwitterChannel** implementation, you must **configure Twitter authentication cookies** so the system can authenticate through `twitter-cli` or the OpenCLI backend. This guide covers the two supported configuration methods, how credentials are persisted, and how to verify they function correctly.

## Manual Configuration via CLI

The fastest way to supply credentials is using the built-in CLI configuration command. Agent-Reach accepts the two required cookies—`auth_token` and `ct0`—either as a formatted string or as separate arguments.

### Using the Cookie String Format

Pass the full cookie header value directly to the `configure` command. The CLI parses this input in `_parse_twitter_cookie_input` within [`agent_reach/cli.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/cli.py) (lines 54-73), which splits the string and stores the values under `twitter_auth_token` and `twitter_ct0` in the configuration file.

```bash
agent-reach configure twitter-cookies "auth_token=AAA; ct0=BBB"

```

### Using Separate Arguments

Alternatively, provide the two tokens as space-separated values without key names:

```bash
agent-reach configure twitter-cookies AAA BBB

```

Both methods write the credentials to `~/.agent-reach/config.yaml` and immediately run a health check against `twitter-cli` to confirm they are valid.

## Automatic Extraction from Browser

If you are already logged into Twitter (x.com) in a desktop browser, Agent-Reach can extract the cookies automatically. This method is implemented in [`agent_reach/cookie_extract.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/cookie_extract.py) and supports Chrome, Firefox, Edge, Brave, and Opera.

Run the following command, replacing `chrome` with your browser name:

```bash
agent-reach configure --from-browser chrome

```

The handler in [`agent_reach/cli.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/cli.py) (`_cmd_configure`, lines 26-34) delegates to `configure_from_browser`, which scans the selected browser’s cookie store for domains `.x.com` and `.twitter.com`. It filters for the required `auth_token` and `ct0` cookies (lines 14-22) and writes them back via `config.set("twitter_auth_token", ...)` and `config.set("twitter_ct0", ...)` (lines 50-58).

## How the Credentials Are Stored and Used

Once configured, Agent-Reach persists the cookies in `~/.agent-reach/config.yaml` as defined in [`agent_reach/config.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/config.py) (lines 24-27). The system synchronizes these credentials across several downstream tools to ensure compatibility:

- **twitter-cli**: The CLI sets environment variables `TWITTER_AUTH_TOKEN` and `TWITTER_CT0` during the health-check phase so `twitter-cli` can read them immediately.
- **xfetch compatibility**: The legacy layer writes the same pair into `~/.config/xfetch/session.json` (lines 76-84 in [`cookie_extract.py`](https://github.com/Panniantong/Agent-Reach/blob/main/cookie_extract.py)).
- **bird CLI**: Agent-Reach can generate a `credentials.env` file for the bird tool (lines 104-112 in [`cookie_extract.py`](https://github.com/Panniantong/Agent-Reach/blob/main/cookie_extract.py)).

## Verifying Your Configuration

After configuration, verify that the Twitter channel is operational using the built-in diagnostic command:

```bash
agent-reach doctor

```

According to the source in [`agent_reach/channels/twitter.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/channels/twitter.py) (lines 59-67), a successful setup reports **"Twitter CLI 完整可用"** (Twitter CLI fully available) or **"OpenCLI 可用"** (OpenCLI available).

For manual verification, export the environment variables and run a status check:

```bash
export TWITTER_AUTH_TOKEN=AAA
export TWITTER_CT0=BBB
twitter status

```

If the output contains `ok: true`, your cookies are valid and the authentication flow is complete.

## Summary

- Agent-Reach requires two cookies—`auth_token` and `ct0`—to authenticate with Twitter, stored in `~/.agent-reach/config.yaml`.
- **Manual configuration** uses `agent-reach configure twitter-cookies` with either a formatted string or separate values, parsed by `_parse_twitter_cookie_input` in [`cli.py`](https://github.com/Panniantong/Agent-Reach/blob/main/cli.py).
- **Automatic extraction** pulls cookies from Chrome, Firefox, Edge, Brave, or Opera using `agent-reach configure --from-browser <browser>`.
- Credentials are synchronized to environment variables and legacy files like `~/.config/xfetch/session.json`.
- Verify the setup with `agent-reach doctor` or by running `twitter status` after exporting `TWITTER_AUTH_TOKEN` and `TWITTER_CT0`.

## Frequently Asked Questions

### Where does Agent-Reach store Twitter cookies?

Agent-Reach stores the `auth_token` and `ct0` values in `~/.agent-reach/config.yaml` under the keys `twitter_auth_token` and `twitter_ct0`, as implemented in [`agent_reach/config.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/config.py) (lines 24-27).

### Which browsers are supported for automatic cookie extraction?

The automatic extraction feature in [`agent_reach/cookie_extract.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/cookie_extract.py) supports Chrome, Firefox, Edge, Brave, and Opera. It scans the browser’s cookie store for domains `.x.com` and `.twitter.com` to retrieve the required tokens.

### How do I verify that my Twitter authentication is working?

Run `agent-reach doctor` and check the Twitter section for the message **"Twitter CLI 完整可用"** or **"OpenCLI 可用"**. Alternatively, manually verify by exporting `TWITTER_AUTH_TOKEN` and `TWITTER_CT0` and running `twitter status` to ensure it returns `ok: true`.

### Can I use the cookies with other Twitter CLI tools?

Yes. Agent-Reach synchronizes credentials to multiple formats: it sets environment variables for `twitter-cli`, writes to `~/.config/xfetch/session.json` for xfetch compatibility, and can generate a `credentials.env` file for the bird CLI, as defined in [`agent_reach/cookie_extract.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/cookie_extract.py) (lines 76-112).