# How to Configure Twitter Cookies Manually Using the Agent-Reach CLI

> Easily configure Twitter cookies manually with the Agent-Reach CLI. Store auth_token and ct0 values in config.yaml using simple commands.

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

---

**Use the `agent-reach configure twitter-cookies` command to store your `auth_token` and `ct0` values in `~/.agent-reach/config.yaml`, either as separate arguments or as a full Cookie header string.**

The Agent-Reach framework requires valid Twitter authentication tokens to enable its Twitter channel functionality. You can persistently store these credentials using the built-in CLI configuration command, which parses, validates, and saves the tokens to your local configuration file.

## Using the `configure twitter-cookies` Command

The CLI provides a dedicated sub-command to handle Twitter authentication setup. When you execute `agent-reach configure twitter-cookies <value>`, the tool performs four distinct operations as implemented in [`agent_reach/cli.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/cli.py).

### Parsing the Input

The command accepts input through the `_parse_twitter_cookie_input` function (lines 54-72 in [`agent_reach/cli.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/cli.py)). It supports two distinct formats:

- **Separate token values**: Provide the `auth_token` and `ct0` as two distinct arguments
- **Full Cookie header**: Provide a complete HTTP Cookie header string containing both values

### Writing to Configuration

After parsing, the tokens are persisted via the `Config.set` API (lines 78-81 in [`agent_reach/cli.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/cli.py)). The values are written to `~/.agent-reach/config.yaml` under the keys `twitter_auth_token` and `twitter_ct0` respectively.

### Validating Credentials

The CLI Optionally verifies the credentials by invoking `twitter status` with the newly-set environment variables `TWITTER_AUTH_TOKEN` and `TWITTER_CT0` (lines 85-100 in [`agent_reach/cli.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/cli.py)). This confirms the cookies work before finalizing the configuration.

### Channel Integration

The `TwitterChannel` class in [`agent_reach/channels/twitter.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/channels/twitter.py) (lines 84-88) checks for these environment variables when probing the `twitter-cli` backend. When present and valid, the channel reports "ok" and becomes available to agents.

## Input Formats and Examples

You can supply the Twitter cookies using either format. Both approaches result in identical configuration entries.

### Method 1: Separate Arguments

Provide the two tokens as distinct values:

```bash
agent-reach configure twitter-cookies abcdef123456 ghijk789012

```

### Method 2: Full Cookie Header

Supply a complete Cookie header string (requires quotes to preserve the argument):

```bash
agent-reach configure twitter-cookies "auth_token=abcdef123456; ct0=ghijk789012; other=ignore"

```

Both commands produce the following entries in your configuration file:

```yaml

# ~/.agent-reach/config.yaml

twitter_auth_token: abcdef123456
twitter_ct0: ghijk789012

```

## Configuration Storage and Verification

The configuration is stored in YAML format in your user directory. After setting the cookies, verify the installation using the built-in diagnostic tool:

```bash
agent-reach doctor

```

Successful configuration displays the Twitter channel status as available, indicating that `twitter-cli` is fully functional for searches, tweets, timelines, and user queries.

## Environment Variable Alternative

For scripts or temporary configurations, you can bypass the config file and export the variables directly:

```bash
export TWITTER_AUTH_TOKEN=abcdef123456
export TWITTER_CT0=ghijk789012
twitter status

```

This approach is useful for CI/CD pipelines or when rotating credentials frequently, though the CLI configuration method provides persistent storage across sessions.

## Summary

- **Use `agent-reach configure twitter-cookies`** to persistently store Twitter authentication tokens
- **Provide tokens** as either separate arguments or a full Cookie header string
- **Storage location** is `~/.agent-reach/config.yaml` under `twitter_auth_token` and `twitter_ct0` keys
- **Validation** occurs automatically via `twitter status` to confirm credentials work
- **Verification** is available through `agent-reach doctor` to check channel status
- **Environment variables** `TWITTER_AUTH_TOKEN` and `TWITTER_CT0` serve as runtime overrides

## Frequently Asked Questions

### What file format does the Agent-Reach CLI expect for Twitter cookies?

The CLI accepts two formats through the `_parse_twitter_cookie_input` function in [`agent_reach/cli.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/cli.py). You can provide the `auth_token` and `ct0` values as two separate command arguments, or as a single quoted string containing a standard HTTP Cookie header with semicolon-separated key-value pairs.

### Where does Agent-Reach store the Twitter authentication tokens?

The tokens are stored in the per-user configuration file at `~/.agent-reach/config.yaml`. The `Config.set` API writes the values under the keys `twitter_auth_token` and `twitter_ct0`, making them available for subsequent CLI operations and channel integrations.

### How can I verify that my Twitter cookies are configured correctly?

Run the `agent-reach doctor` command to check the status of all configured channels. If the cookies are valid, the output will show the Twitter channel as "ok" and indicate that `twitter-cli` is fully available for searches, reading tweets, timelines, and user queries.

### Can I use environment variables instead of the configuration file?

Yes. The `TwitterChannel` implementation in [`agent_reach/channels/twitter.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/channels/twitter.py) checks for the environment variables `TWITTER_AUTH_TOKEN` and `TWITTER_CT0` when probing the backend. Exporting these variables allows you to use Twitter functionality without modifying the config file, though settings in the config file provide persistence across terminal sessions.