# How to Manually Configure Twitter Cookies in Agent Reach

> Learn to manually configure Twitter cookies in Agent Reach. Extract auth token and ct0 values and run agent reach configure twitter-cookies to store them and validate access via twitter-cli.

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

---

**To manually configure Twitter cookies in Agent Reach, extract the `auth_token` and `ct0` values from your browser and run `agent-reach configure twitter-cookies AUTH_TOKEN CT0`, which stores them in `~/.agent-reach/config.yaml` and validates access via `twitter-cli`.**

Agent Reach requires two specific authentication tokens from X (formerly Twitter) to enable platform interactions. This guide covers the manual configuration process for the `auth_token` and `ct0` cookies, showing exactly how they are parsed, stored, and validated according to the Panniantong/Agent-Reach source code.

## Required Twitter Authentication Cookies

Agent Reach depends on two specific cookies that X uses to maintain authenticated sessions:

- **`auth_token`**: The primary session token identifying your X account.
- **`ct0`**: The CSRF token required for API requests.

These values are persisted in your local configuration file at `~/.agent-reach/config.yaml` under the keys `twitter_auth_token` and `twitter_ct0`. The `Config` class in [`agent_reach/config.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/config.py) handles the persistence layer, using `Config.set()` to write these sensitive values to disk.

## Manual Configuration Methods

The CLI supports two input formats for manual configuration, both processed by the `_parse_twitter_cookie_input` function in [`agent_reach/cli.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/cli.py) (lines 24-42).

### Method 1: Direct Token Arguments

Pass the two tokens as separate positional arguments:

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

```

This is the most explicit method, sending the values directly to the configuration handler without additional parsing.

### Method 2: Raw Cookie Header String

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

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

```

The parser extracts only the `auth_token` and `ct0` key-value pairs, ignoring unrelated cookies. This method is useful when copying directly from Chrome's "Copy > Copy Cookies" feature.

## How Agent Reach Validates Your Cookies

After storing the values, the CLI validates them immediately. In [`agent_reach/cli.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/cli.py) (lines 65-78), the `_cmd_configure` function performs a live test by:

1. Injecting the tokens into the environment variables `TWITTER_AUTH_TOKEN` and `TWITTER_CT0`.
2. Executing `twitter status` via `subprocess.run`.
3. Checking the output for `"ok: true"`.

If validation succeeds, you will see:

```

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

```

If the check fails, the CLI reports an error and allows you to re-run the configuration step.

## Cookie Storage and Downstream Sync

Agent Reach distributes your credentials to multiple destinations to ensure compatibility with various helper tools:

- **Agent Reach Config**: Written to `~/.agent-reach/config.yaml` via `Config.set("twitter_auth_token", ...)` and `Config.set("twitter_ct0", ...)`.
- **twitter-cli Environment**: Temporarily exported as `TWITTER_AUTH_TOKEN` and `TWITTER_CT0` environment variables during validation and usage.
- **xfetch Legacy**: Copied to `~/.config/xfetch/session.json` via the `_sync_xfetch_session` function in [`agent_reach/cookie_extract.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/cookie_extract.py) for backward compatibility.
- **bird-cli**: Written as a source-able environment file to `~/.config/bird/credentials.env` via `_sync_bird_env`.

## Summary

- **Manual configuration** requires the `auth_token` and `ct0` cookies from your X (Twitter) session.
- Use `agent-reach configure twitter-cookies` with either separate arguments or a raw cookie header string.
- The CLI validates credentials instantly by running `twitter status` and checking for `"ok: true"`.
- Credentials are stored in `~/.agent-reach/config.yaml` and synchronized to legacy tools like `xfetch` and `bird`.
- All parsing logic resides in [`agent_reach/cli.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/cli.py), while storage and sync operations are handled by [`agent_reach/config.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/config.py) and [`agent_reach/cookie_extract.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/cookie_extract.py).

## Frequently Asked Questions

### Where do I find the auth_token and ct0 cookies?

Open your browser's Developer Tools, navigate to the Application (Chrome) or Storage (Firefox) tab, and locate the Cookies section for `twitter.com` or `x.com`. Copy the values for `auth_token` and `ct0`. Alternatively, use the browser's "Copy as cURL" feature and extract the values from the cookie string.

### What file format does Agent Reach use to store Twitter cookies?

Agent Reach stores the cookies in a YAML configuration file at `~/.agent-reach/config.yaml` under the keys `twitter_auth_token` and `twitter_ct0`. The `Config` class provides methods to read and write these values securely, and the CLI masks sensitive fields when displaying configuration summaries.

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

The CLI validates cookies by temporarily setting them as environment variables and executing `twitter status` via `subprocess.run`. It checks the command output for the string `"ok: true"`. This verification ensures that the tokens are active and correctly formatted before the configuration step completes.

### Can I configure Twitter cookies without installing browser extraction tools?

Yes. While Agent Reach supports automatic extraction via `agent-reach configure --from-browser`, you can manually configure cookies without any browser extraction dependencies. Simply obtain the `auth_token` and `ct0` values from your browser's developer tools and run the manual configuration command with the two token values.