# How to Configure Reddit Authentication Using rdt-cli with Cookies in Agent-Reach

> Configure Reddit authentication in Agent-Reach using rdt-cli. Learn to extract the reddit_session cookie automatically or manually for seamless integration.

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

---

**To configure Reddit authentication in Agent-Reach, install rdt-cli ≥0.4.2, run `rdt login` to automatically extract the `reddit_session` cookie, or manually create `~/.config/rdt-cli/credential.json` with the cookie value if browser automation fails.**

Agent-Reach monitors Reddit posts and comments through the upstream tool **rdt-cli** (public-clis/rdt-cli), which now requires a valid Reddit session cookie following the platform's 2024 authentication mandate. This guide walks through the exact implementation found in the [Panniantong/Agent-Reach](https://github.com/Panniantong/Agent-Reach) source code to establish authenticated access using both automatic and manual cookie extraction methods.

## Prerequisites: Install rdt-cli

Before configuring authentication, you must install **rdt-cli** version 0.4.2 or higher. The installer logic in [`agent_reach/cli.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/cli.py) (lines 31-40) references this dependency as the foundation for Reddit channel operations.

```bash
pipx install "rdt-cli>=0.4.2"

```

## Automatic Authentication via Browser Login

The preferred method uses rdt-cli's built-in browser automation to capture the session cookie without manual copying.

### Run the Login Command

Execute the following command to open your default browser and initiate authentication:

```bash
rdt login

```

This command directs you to *reddit.com* to log in normally. Upon successful authentication, rdt-cli automatically extracts the `reddit_session` cookie and stores it in your local configuration directory. This workflow eliminates the need to manually handle cookie strings.

## Manual Cookie Configuration (Fallback)

If automatic extraction fails—common with Chrome 127+ security restrictions or headless environments—you can manually supply the cookie.

### Extract the Cookie with Cookie-Editor

1. Install the **Cookie-Editor** browser extension (available for Chrome and Firefox).
2. Navigate to reddit.com and ensure you are logged into your account.
3. Click the Cookie-Editor icon and locate the `reddit_session` entry.
4. Copy the **Value** field (this is your session token).

### Create the Credential File

According to [`agent_reach/channels/reddit.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/channels/reddit.py) (lines 30-73), rdt-cli expects a specific JSON structure at `~/.config/rdt-cli/credential.json`. Create this file with your extracted cookie:

```bash
cat > ~/.config/rdt-cli/credential.json <<EOF
{
  "cookies": { "reddit_session": "YOUR_SESSION_VALUE_HERE" },
  "source": "manual",
  "username": "your_reddit_username",
  "modhash": null,
  "saved_at": 0,
  "last_verified_at": null
}
EOF

```

Replace `YOUR_SESSION_VALUE_HERE` with the cookie value copied from Cookie-Editor.

## Verifying Authentication

Once configured, verify that Agent-Reach can authenticate with Reddit's API.

### Check rdt-cli Status

Run the status command to confirm the credential file is valid:

```bash
rdt status --json

```

A successful configuration returns `"authenticated": true` along with your username.

### Validate via Agent-Reach Doctor

The **RedditChannel** class in [`agent_reach/channels/reddit.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/channels/reddit.py) (lines 54-58) implements a `check()` method used by the `agent-reach doctor` command. You can verify programmatically:

```python
from agent_reach.channels.reddit import RedditChannel

status, message = RedditChannel().check()
print(status, message)  # Output: ok Reddit rdt-cli 可用（已登录：username）

```

When the credential file is properly configured, the channel reports status as *ok* and no further configuration is required.

## Summary

- **Install** rdt-cli ≥0.4.2 as the foundation for Reddit access in Agent-Reach.
- **Automatic method**: Run `rdt login` to let the tool extract the `reddit_session` cookie via browser automation.
- **Manual fallback**: Use Cookie-Editor to copy the `reddit_session` value and write it to `~/.config/rdt-cli/credential.json` using the exact JSON schema defined in [`agent_reach/channels/reddit.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/channels/reddit.py).
- **Verify** authentication by running `rdt status --json` or calling `RedditChannel().check()` to ensure Agent-Reach reports the channel as operational.

## Frequently Asked Questions

### What should I do if `rdt login` fails to open the browser?

If the automatic login fails due to browser restrictions or headless server environments, manually extract the `reddit_session` cookie using the Cookie-Editor extension and create the credential file at `~/.config/rdt-cli/credential.json` with the JSON format specified in [`agent_reach/channels/reddit.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/channels/reddit.py).

### Where does Agent-Reach store the Reddit authentication credentials?

rdt-cli stores credentials in `~/.config/rdt-cli/credential.json`. The **RedditChannel** class reads this file via the `rdt status` command to verify authentication state without requiring additional configuration in Agent-Reach itself.

### How do I know if my Reddit authentication is working in Agent-Reach?

Run `rdt status --json` and look for `"authenticated": true` in the output. Alternatively, execute the Python check `RedditChannel().check()` from [`agent_reach/channels/reddit.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/channels/reddit.py), which returns `"ok"` and your username if the session cookie is valid.

### Which version of rdt-cli is required for Agent-Reach?

Agent-Reach requires **rdt-cli ≥0.4.2**, as referenced in the installer logic at [`agent_reach/cli.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/cli.py) (lines 31-40). Earlier versions may lack the authentication mechanisms necessary for Reddit's current API requirements.