# How to Use the Agent-Reach Configure Command with Browser Cookie Extraction

> Easily configure Agent-Reach for Twitter X, Bilibili, and more. Use the agent-reach configure command to extract browser cookies from Chrome, Firefox, Edge, or Safari for automatic authentication.

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

---

**TLDR:** Run `agent-reach configure --from-browser <browser>` to automatically extract authentication cookies from your local Chrome, Firefox, Edge, or Safari browser and populate your `~/.agent-reach/config.yaml` with credentials for Twitter/X, XiaoHongShu, Bilibili, and Xueqiu.

The **Agent-Reach** CLI provides a `configure` sub-command that eliminates manual cookie copying by reading authentication tokens directly from your browser's cookie store. This automation supports multiple social platforms and handles the complex mapping of browser cookies to configuration keys required by the tool.

## Basic Command Syntax

The browser extraction flag attaches to the standard configure command:

```bash
agent-reach configure --from-browser <BROWSER>

```

Supported browser values include `chrome`, `firefox`, `edge`, and `safari`. The command requires the browser to be installed on your local machine and accessible in standard profile directories.

## How Browser Cookie Extraction Works

The extraction pipeline implemented in [`agent_reach/cookie_extract.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/cookie_extract.py) follows a four-stage process when triggered from the CLI entry point.

### Step 1: CLI Argument Parsing and Dispatch

In [`agent_reach/cli.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/cli.py) (lines 81-91), the `configure` sub-parser defines the `--from-browser` option. When invoked, the `_cmd_configure` handler (lines 26-34) detects this flag and immediately routes execution to `configure_from_browser` instead of the interactive configuration mode.

### Step 2: Cookie Extraction Backend Selection

The `extract_all(browser)` function in [`agent_reach/cookie_extract.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/cookie_extract.py) (lines 53-66) attempts to import **rookiepy** (a Rust-based extractor) as the preferred engine, falling back to **browser-cookie3** if unavailable. This backend opens the browser’s SQLite cookie store and iterates over all stored cookies, matching them against the **PLATFORM_SPECS** table defined in lines 13-39.

The function returns a dictionary mapping platform keys (`twitter`, `xhs`, `bilibili`, `xueqiu`) to their respective extracted cookie data (lines 42-52).

### Step 3: Platform-Specific Cookie Mapping

`configure_from_browser` processes the extraction results and transforms browser cookie names into Agent-Reach configuration keys:

- **Twitter/X**: Extracts `auth_token` and `ct0`, storing them as `twitter_auth_token` and `twitter_ct0` (lines 50-58). The function also synchronizes these values to the legacy `xfetch` session file and the `bird` environment file.
- **XiaoHongShu**: Saves the complete cookie string as `xhs_cookie` (lines 66-72).
- **Bilibili**: Maps `SESSDATA` to `bilibili_sessdata` and optional `bili_jct` to `bilibili_csrf` (lines 73-80).
- **Xueqiu**: Persists cookies only if the required `xq_a_token` is present, saving it as `xueqiu_token` (lines 85-92).

### Step 4: Configuration Persistence

All extracted values are written to the user-level configuration file (`~/.agent-reach/config.yaml`) via the `Config.set` method from [`agent_reach/config.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/config.py). The utility uses `make_private_dir` from [`agent_reach/utils/paths.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/utils/paths.py) to ensure secure file permissions during creation.

## Practical Examples

Extract from Chrome (the default choice for most desktop environments):

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

```

Extract from Firefox on Linux systems where it is the default browser:

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

```

Successful execution produces formatted output indicating which platforms were configured:

```

Extracting cookies from chrome...

  ✅ Twitter/X: auth_token + ct0
  ✅ XiaoHongShu: 12 cookies
  ✅ Bilibili: SESSDATA + bili_jct
  ✅ Xueqiu: 7 cookies (含 xq_a_token)

✅ Cookies configured! Run `agent-reach doctor` to see updated status.

```

## Troubleshooting Browser Access Issues

If the browser is currently running or the cookie database is locked, the extraction will fail silently for that specific browser. The console output displays a warning indicator:

```

  -- Could not read browser cookies (browser might be open or password was denied)

```

To resolve this, close the browser completely before running the command. Ensure your user account has read permissions to the browser's profile directory (typically `~/Library/Application Support/Google/Chrome` on macOS or `~/.config/google-chrome` on Linux).

## Summary

- The `agent-reach configure --from-browser <browser>` command automates cookie extraction from local browser stores.
- The implementation in [`agent_reach/cookie_extract.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/cookie_extract.py) uses **rookiepy** or **browser-cookie3** to read SQLite cookie databases.
- Supports four platforms: Twitter/X, XiaoHongShu, Bilibili, and Xueqiu, with specific mappings to configuration keys.
- Credentials are persisted to `~/.agent-reach/config.yaml` via the `Config.set` method.
- Always run `agent-reach doctor` after configuration to verify platform connectivity.

## Frequently Asked Questions

### Which browsers are supported for cookie extraction?

Agent-Reach supports Chrome, Firefox, Edge, and Safari. The underlying extraction logic in [`agent_reach/cookie_extract.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/cookie_extract.py) attempts to locate the standard profile directories for each browser, though availability depends on your operating system and installation method.

### What happens if my browser is running when I execute the command?

If the browser process is active, the cookie database file remains locked, preventing read access. The CLI will display a warning message (`-- Could not read browser cookies...`) and skip that browser. You must close the browser completely before extraction.

### How are the extracted cookies stored on my system?

Cookies are written to the YAML configuration file at `~/.agent-reach/config.yaml` using the `Config.set` method. Twitter/X cookies receive special handling—they are simultaneously synced to supplemental files including the `xfetch` session store and `bird` environment configuration to maintain compatibility with legacy workflows.

### Do I need to install additional Python packages for this to work?

The system attempts to use **rookiepy** first (a Rust-based extractor), but falls back to **browser-cookie3** if unavailable. If neither package is installed, the extraction will fail. Most standard installations include one of these dependencies, but you can manually install `browser-cookie3` via pip if you encounter import errors.