Exporting Chrome/Firefox Cookies for Agent-Reach Configuration: A Complete Guide

Export cookies from Chrome or Firefox using a browser extension like Cookie-Editor, save the JSON file, then run agent-reach configure --cookies <path> to authenticate your AI agents across Twitter, Reddit, and other platforms.

Agent-Reach is a Python CLI/library that enables AI agents to read and search protected web content across platforms like Twitter/X, Reddit, and YouTube. Unlike tools that embed browser automation, Agent-Reach requires users to supply authentication cookies exported from their browsers. This guide explains the exact process for exporting Chrome and Firefox cookies and configuring them for Agent-Reach using the CookieExtractor class defined in agent_reach/cookie_extract.py.

Agent-Reach deliberately avoids interactive OAuth flows to support headless CI/CD pipelines. Many platforms (Twitter/X, Xiaohongshu, etc.) rely on cookie-based session authentication for their public web endpoints rather than API keys. By parsing a JSON file exported from browser extensions like Cookie-Editor or EditThisCookie, the tool lets you control exactly what authentication data is shared while maintaining the ability to run in automated environments.

The Role of CookieExtractor

The CookieExtractor class in agent_reach/cookie_extract.py serves as the central parser for your exported cookies. It validates required fields (name, value, domain) and builds a domain-to-cookie-header mapping. When a channel performs an API call, it retrieves the formatted cookie string via CookieExtractor.get_for(domain) and attaches it to the HTTP request header as Cookie: auth_token=…; ct0=….

Step 1: Export Cookies from Your Browser

Install a cookie-export extension such as Cookie-Editor (available for Chrome and Firefox). Navigate to the website you want to access (e.g., twitter.com), open the extension, and click Export → JSON. Save this file to a secure location like ~/.agent-reach/cookies.json.

The JSON format follows the standard Cookie-Editor schema with objects containing name, value, domain, and other cookie attributes.

Step 2: Configure Agent-Reach

Register the cookie file using the CLI command defined in agent_reach/cli.py:

python -m agent_reach.cli configure --cookies ~/.agent-reach/cookies.json

This command stores the absolute path in the user configuration file (~/.config/agent-reach/config.yaml) and validates the JSON structure by calling CookieExtractor.load(path).

Alternatively, set the environment variable:

export AGENT_REACH_COOKIES=~/.agent-reach/cookies.json

Step 3: Channel Authentication Check

Each platform channel (e.g., agent_reach/channels/twitter.py) implements a check() method that calls CookieExtractor.get_for(domain). If required cookies are missing, the channel raises a descriptive error directing you back to the export step.

Practical Code Examples

CLI Usage After Configuration

After running the configure command, read protected content without manual cookie handling:

python -m agent_reach.cli read https://twitter.com/your_private_account

The twitter channel automatically attaches the auth_token and ct0 cookies from your exported file to the request headers.

Programmatic Library Usage

Access cookies directly in Python scripts:

from agent_reach.core import AgentReach
from agent_reach.cookie_extract import CookieExtractor

# Load cookies explicitly (optional if configured via CLI)

CookieExtractor.load("~/.agent-reach/cookies.json")

ar = AgentReach()
content = ar.read("https://twitter.com/your_private_account")
print(content)

Refreshing Expired Cookies

Cookies typically expire after a few weeks. Re-export from your browser and re-run the configure command:

python -m agent_reach.cli configure --cookies ~/.agent-reach/cookies.json

The new file overwrites the saved path; no further code changes are required.

Security Best Practices

Treat the exported JSON file as a sensitive secret equivalent to your login credentials. Never commit it to public repositories. Store it in a directory listed in .gitignore or load it exclusively via the AGENT_REACH_COOKIES environment variable. The file contains session tokens that grant access to your authenticated accounts.

Verifying Configuration with Agent-Reach Doctor

Use the diagnostic tool implemented in agent_reach/doctor.py to verify your cookie setup:

python -m agent_reach.cli doctor

This command checks that the cookie file exists, parses correctly, and contains valid entries for configured channels.

Summary

  • Agent-Reach requires browser cookies exported as JSON to authenticate with platforms like Twitter/X and Reddit.
  • The CookieExtractor class in agent_reach/cookie_extract.py parses exports from Chrome/Firefox extensions like Cookie-Editor.
  • Configure the tool using agent-reach configure --cookies <path> or the AGENT_REACH_COOKIES environment variable.
  • Each channel's check() method validates domain-specific cookies before making requests.
  • Refresh cookies periodically and use agent-reach doctor to troubleshoot configuration issues.

Frequently Asked Questions

What browser extensions work with Agent-Reach?

Any extension that exports cookies in the standard JSON format used by Cookie-Editor or EditThisCookie works. Popular options include Cookie-Editor (Chrome/Firefox) and EditThisCookie. The JSON must contain name, value, and domain fields for each cookie to pass validation in agent_reach/cookie_extract.py.

Why does Agent-Reach use cookies instead of OAuth?

Agent-Reach avoids interactive OAuth flows to enable headless operation in CI/CD pipelines. Many platforms still rely on cookie-based authentication for their public web endpoints, and cookies provide precise user control over what authentication data is shared without requiring API keys or complex token refresh logic.

How do I know when my cookies have expired?

If you receive authentication errors when reading protected content, your cookies likely expired. Run agent-reach doctor to validate the cookie file, or check the specific channel's check() method output. Cookies typically last a few weeks; re-export them from your browser and re-run the configure command to refresh.

The current implementation stores a single cookie file path in the configuration. However, a single JSON export can contain cookies for multiple domains (twitter.com, reddit.com, etc.), which CookieExtractor parses into separate domain mappings. For distinct identities across platforms, switch cookie files by re-running the configure command or using the AGENT_REACH_COOKIES environment variable.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →