# How to Configure Twitter/X Authentication with Cookies in Agent Reach

> Learn how to configure Twitter X authentication and cookies in Agent Reach. Easily set up API access using CLI or browser extraction for seamless integration.

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

---

**Agent Reach requires two authentication cookies (`auth_token` and `ct0`) from X (formerly Twitter) to enable API access, which can be configured manually via CLI or extracted automatically from supported browsers.**

To enable Twitter/X integration, Agent Reach must authenticate using session cookies from your X account. According to the Agent-Reach source code, the application specifically looks for the **`auth_token`** and **`ct0`** cookies, storing them persistently in your local configuration. You can supply these credentials either by manually pasting them into the CLI or by allowing the tool to extract them directly from Chrome, Firefox, Edge, Brave, or Opera.

## Required Authentication Cookies

X (Twitter) uses two distinct cookies to maintain an authenticated session. Agent Reach maps these to internal configuration keys:

- **`auth_token`** → stored as `twitter_auth_token` in `~/.agent-reach/config.yaml`
- **`ct0`** → stored as `twitter_ct0` in the same configuration file

These values are defined as required keys in [`agent_reach/config.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/config.py)【https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/config.py#L22-L25】, where the `Config` class manages persistence. When set, the CLI automatically synchronizes these credentials to downstream tools including `twitter-cli`, `xfetch`, and `bird-cli`.

## Configuration Methods

Agent Reach provides two distinct paths for supplying Twitter/X credentials. Both methods ultimately write to the same configuration keys and validate access by invoking `twitter status` via subprocess.

### Manual Configuration via CLI

The most direct method uses the `configure twitter-cookies` command. The CLI accepts either individual cookie values or a raw header string.

Provide cookies as separate arguments:

```bash
agent-reach configure twitter-cookies YOUR_AUTH_TOKEN_VALUE YOUR_CT0_VALUE

```

Or paste a raw cookie header (copied directly from Chrome's "Copy > Copy Cookies"):

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

```

The parsing logic in [`agent_reach/cli.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/cli.py) handles both formats through `_parse_twitter_cookie_input` (lines 24-42)【https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/cli.py#L24-L42】. After successful storage, the CLI runs a validation check and outputs:

```

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

```

### Automatic Extraction from Browser

For convenience, Agent Reach can extract cookies directly from your local browser profile using the `rookiepy` or `browser-cookie3` libraries.

Run the browser extraction command:

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

```

Replace `chrome` with `firefox`, `edge`, `brave`, or `opera` as needed.

Under the hood, `configure_from_browser` in [`agent_reach/cookie_extract.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/cookie_extract.py) iterates through supported platforms, extracts the specific cookies, and persists them:

```python

# 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"])

```

This method also syncs credentials to legacy tool locations, including `~/.config/xfetch/session.json` and `~/.config/bird/credentials.env`【https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/cookie_extract.py#L18-L35】.

## Validation and Storage Sync

Once configured, Agent Reach validates the cookies by executing `twitter status` and checking for `"ok: true"` in the output. If validation fails, the CLI reports an error and allows reconfiguration.

The credentials propagate to three destinations:

1. **Agent Reach config** (`~/.agent-reach/config.yaml`) - Persistent YAML storage via `Config.set()`
2. **Environment variables** (`TWITTER_AUTH_TOKEN`, `TWITTER_CT0`) - Injected into the process environment for `twitter-cli` calls【https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/cli.py#L65-L78】
3. **Legacy tool files** - Synchronized to `xfetch` and `bird` configuration paths for backward compatibility

## Summary

- **Agent Reach requires two specific cookies**: `auth_token` and `ct0` from X (Twitter).
- **Storage location**: `~/.agent-reach/config.yaml` under keys `twitter_auth_token` and `twitter_ct0`.
- **Manual method**: Use `agent-reach configure twitter-cookies` with either separate values or a raw cookie header.
- **Automatic method**: Use `agent-reach configure --from-browser <browser>` to extract from Chrome, Firefox, Edge, Brave, or Opera.
- **Validation**: The CLI tests cookies by running `twitter status` and checking for `"ok: true"`.
- **Sync**: Credentials automatically propagate to `twitter-cli`, `xfetch`, and `bird` tools.

## Frequently Asked Questions

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

Agent Reach persists the `auth_token` and `ct0` values in `~/.agent-reach/config.yaml` under the keys `twitter_auth_token` and `twitter_ct0`. This file is managed by the `Config` class in [`agent_reach/config.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/config.py). The values are also synchronized to environment variables and legacy tool configuration files for compatibility with `xfetch` and `bird-cli`.

### Can I use a raw cookie header string instead of individual values?

Yes. The CLI accepts a full cookie header string (such as `"auth_token=AAA; ct0=BBB; other=ignore"`) and parses it automatically using the `_parse_twitter_cookie_input` helper function in [`agent_reach/cli.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/cli.py). This is useful when copying cookies directly from browser developer tools.

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

Agent Reach supports automatic extraction from Chrome, Firefox, Edge, Brave, and Opera. The `configure_from_browser` function in [`agent_reach/cookie_extract.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/cookie_extract.py) uses `rookiepy` or `browser-cookie3` libraries to read the browser's SQLite cookie database and extract the specific X (Twitter) authentication cookies.

### How does Agent Reach validate the configured cookies?

After storing the cookies, Agent Reach validates them by invoking `twitter status` via `subprocess.run` and checking the output for `"ok: true"`. This verification step is implemented in the `_cmd_configure` function in [`agent_reach/cli.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/cli.py) (lines 65-78). If the check fails, the CLI displays an error message, allowing you to re-run the configuration.