How to Configure YouTube Cookies in Agent-Reach for Age-Restricted Videos

Use the agent-reach configure youtube-cookies <source> command to store your browser cookies or a cookie file path, enabling yt-dlp to authenticate and access age-restricted or member-only content.

Agent-Reach is an open-source automation framework that relies on yt-dlp to extract YouTube video metadata and subtitles. When accessing age-restricted or membership-gated content, the tool must present valid authentication cookies from a logged-in browser session. Configuring YouTube cookies allows the agent to bypass restrictions automatically without manual credential entry.

Why YouTube Cookies Are Required

Agent-Reach delegates all video fetching operations to yt-dlp, which cannot bypass age verification gates or membership paywalls without authentication tokens. The framework stores your cookie source in ~/.agent-reach/config.yaml under the key youtube_cookies_from. During execution, the agent passes this value to yt-dlp using either the --cookies-from-browser or --cookies parameter, allowing seamless access to restricted content.

You can configure Agent-Reach to retrieve cookies using two distinct methods.

Browser-Based Authentication

The most common approach extracts cookies directly from your logged-in browser profile. Agent-Reach supports Chrome, Firefox, Edge, Brave, and Opera. This method requires Node.js or Deno installed on your system, as yt-dlp uses a JavaScript runtime to decrypt browser cookies.

File-Based Authentication

Alternatively, export your YouTube cookies to a Netscape-formatted text file using a browser extension like Cookie-Editor. Provide the absolute path to this file when configuring the agent. This method works independently of installed browsers but requires manual cookie export updates when sessions expire.

Step-by-Step Configuration

Configure Cookies from Browser

Run the configure command with your browser name:

agent-reach configure youtube-cookies chrome

This stores the value in ~/.agent-reach/config.yaml:

youtube_cookies_from: chrome

Configure Cookies from File

Export cookies to ~/my_youtube_cookies.txt, then run:

agent-reach configure youtube-cookies ~/my_youtube_cookies.txt

The configuration file now contains:

youtube_cookies_from: /home/youruser/my_youtube_cookies.txt

Verify the Configuration

Run the diagnostic command to confirm your setup:

agent-reach doctor

You should see output confirming:


✅ YouTube cookie source configured: chrome

The check() method in agent_reach/channels/youtube.py (lines 23-46) validates that yt-dlp is installed and that a JavaScript runtime is available. If Node.js or Deno is missing, the CLI suggests running agent-reach install or displays the fix command generated by render_ytdlp_fix_command() in agent_reach/utils/paths.py (lines 29-45).

How the Configuration Works Internally

When you issue a YouTube request, the agent reads the stored configuration and constructs the appropriate yt-dlp command.

In agent_reach/cli.py at line 1108, the configure subcommand executes config.set("youtube_cookies_from", value), persisting your choice to disk. During video fetching, the agent injects the cookie parameter into the yt-dlp invocation:


# Browser source example:

yt-dlp --dump-json --cookies-from-browser chrome "https://youtube.com/watch?v=EXAMPLE"

# File source example:

yt-dlp --dump-json --cookies /home/youruser/my_youtube_cookies.txt "https://youtube.com/watch?v=EXAMPLE"

The agent_reach/config.py file (lines 79-84) handles the set() and get() operations for the configuration store. Documentation in agent_reach/skill/references/video.md (line 69) explicitly recommends using --cookies-from-browser for restricted videos.

Summary

  • Agent-Reach uses yt-dlp to fetch YouTube metadata, which requires authentication for age-restricted content.
  • Configure cookies using agent-reach configure youtube-cookies <browser_name> or agent-reach configure youtube-cookies <path_to_file>.
  • Configuration is stored in ~/.agent-reach/config.yaml under the key youtube_cookies_from.
  • Verification via agent-reach doctor ensures yt-dlp and JavaScript runtimes are properly configured.
  • Privacy is maintained—cookies remain local and are never uploaded to remote servers.

Frequently Asked Questions

How do I know if my cookies are working correctly?

Run agent-reach doctor to verify the configuration is recognized. Then attempt to fetch an age-restricted video URL. If the agent returns metadata and subtitles without errors, the cookies are functioning. If you encounter authentication errors, ensure you are logged into YouTube in the specified browser or update your exported cookie file.

Yes. Simply re-run agent-reach configure youtube-cookies with the new browser name or file path. The new value overwrites the previous entry in ~/.agent-reach/config.yaml. The config.set() method in agent_reach/config.py handles updates atomically.

Why does yt-dlp require Node.js or Deno for browser cookies?

Modern browsers encrypt their cookie stores using system-level security features. yt-dlp uses a JavaScript runtime to execute decryption scripts that extract the session tokens. The YouTubeChannel.check() method in agent_reach/channels/youtube.py verifies this dependency exists; if missing, use the command output by render_ytdlp_fix_command() in agent_reach/utils/paths.py to add --js-runtimes node to your yt-dlp configuration.

Is it safe to store my YouTube cookies in Agent-Reach?

Yes. The cookies are stored locally in your ~/.agent-reach/config.yaml file and are never transmitted to external servers. The framework only uses these credentials to construct local yt-dlp commands. Ensure your user directory has appropriate file permissions to prevent unauthorized access to the configuration file.

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 →