How to Configure LinkedIn Access When Jina Reader Fails in Agent-Reach

When Jina Reader fails to retrieve LinkedIn content, Agent-Reach automatically falls back to a dedicated LinkedIn backend that authenticates via browser cookies exported from your logged-in session.

Agent-Reach provides a unified CLI-driven interface for reading content across internet platforms, including LinkedIn. When the default Jina Reader backend encounters rate limits, network blocks, or content-type mismatches on LinkedIn URLs, the system automatically falls back to the platform-specific channel implemented in agent_reach/channels/linkedin.py. This guide explains how to configure the cookie-based authentication required to enable this fallback mechanism according to the Panniantong/Agent-Reach source code.

Export LinkedIn Cookies from Your Browser

LinkedIn does not expose a public API for content scraping, so Agent-Reach authenticates using browser cookies exported from an active logged-in session.

  1. Open LinkedIn in your web browser and log into your account.
  2. Install the Cookie-Editor browser extension (or similar tool).
  3. Click the extension icon and select Export to copy all cookies as a JSON string.
  4. Save this JSON string for the next step.

The exported data must contain essential authentication tokens such as li_at and JSESSIONID to maintain your session.

Store the exported cookies in the Agent-Reach configuration file to allow the LinkedIn channel to inject them into request headers.

Edit ~/.agent_reach/config.yaml and add a linkedin section containing the raw JSON string:

linkedin:
  cookies: |
    {"li_at":"AQED...","JSESSIONID":"ajax:1234567890"}

Ensure the cookies field contains a raw JSON string without trailing commas. The configuration loader in agent_reach/config.py parses this value and passes it to the LinkedIn channel implementation.

Enable the Fallback Chain in agent_reach/core.py

The global backend order is defined in agent_reach/core.py under the BACKENDS list. By default, this list is ["opencli", "jina_reader"].

To enable LinkedIn as a fallback when Jina Reader fails, modify the list to include "linkedin" after "jina_reader":

BACKENDS = ["opencli", "jina_reader", "linkedin"]

This ordering ensures that when the read method in agent_reach/channels/linkedin.py raises a BackendError (caught from requests.exceptions.RequestException), the core router automatically tries the next backend in the sequence.

You can also override this order at runtime using the CLI flag:

python -m agent_reach.cli read https://www.linkedin.com/pulse/example-article --backend-order=jina_reader,linkedin

Verify Configuration with the Doctor Command

Run the diagnostic tool to ensure the LinkedIn channel can authenticate and reach the platform:

python -m agent_reach.cli doctor

The doctor command invokes linkedin.check() from agent_reach/doctor.py and validates that:

  • The cookies are correctly parsed from the configuration
  • The HTTP headers can be constructed with the Cookie field
  • The endpoint is reachable

Expect output similar to:

✅ LinkedIn ready

If you see errors, verify that your JSON cookie string is properly formatted and contains valid session tokens.

How the Fallback Mechanism Works

When you request a LinkedIn article, the core router iterates through the BACKENDS list in agent_reach/core.py:

  1. Jina Reader attempt: The system first tries Jina Reader. If it encounters rate limits or blocks, it returns a failure.
  2. LinkedIn fallback: The router catches the failure and logs "🔄 Falling back to LinkedIn backend".
  3. Cookie injection: The read method in agent_reach/channels/linkedin.py injects the exported cookies into the HTTP request headers (Cookie: ...) before issuing the GET request.
  4. Content retrieval: With valid authentication, the LinkedIn backend retrieves the article content and returns it to the CLI.

This channel-based architecture ensures that can_handle, read, search, and check methods follow the BaseChannel contract, allowing the router to treat LinkedIn interchangeably with generic backends.

Summary

  • Export cookies from your logged-in LinkedIn session using Cookie-Editor to obtain a JSON string containing li_at and JSESSIONID.
  • Configure ~/.agent_reach/config.yaml with the linkedin.cookies field set to the raw JSON string.
  • Modify BACKENDS in agent_reach/core.py to place "linkedin" after "jina_reader" in the fallback chain.
  • Verify setup using python -m agent_reach.cli doctor to ensure linkedin.check() reports success.
  • Runtime override is available via --backend-order=jina_reader,linkedin for specific CLI invocations.

Frequently Asked Questions

Why does Jina Reader fail on LinkedIn pages?

Jina Reader often fails due to rate limiting, network blocks, or content-type restrictions imposed by LinkedIn's anti-scraping measures. When requests.exceptions.RequestException occurs, the Agent-Reach core router catches the error and triggers the fallback to the dedicated LinkedIn backend implemented in agent_reach/channels/linkedin.py.

Which specific cookies must I export from LinkedIn?

You must export the li_at and JSESSIONID cookies at minimum. These tokens maintain your authenticated session with LinkedIn. The li_at cookie contains your authentication token, while JSESSIONID identifies your session. Store these as a raw JSON string in the linkedin.cookies configuration field.

Can I use the LinkedIn backend as the primary instead of a fallback?

Yes. While the default BACKENDS list in agent_reach/core.py prioritizes Jina Reader, you can reorder the list to ["opencli", "linkedin"] or use the runtime flag --backend-order=linkedin to attempt LinkedIn first. This bypasses Jina Reader entirely for LinkedIn URLs, though you lose the benefit of Jina's content extraction for other sites.

How do I troubleshoot if the doctor command shows LinkedIn is not ready?

First, verify your cookie JSON syntax is valid with no trailing commas or formatting errors. Second, ensure the cookies haven't expired by logging into LinkedIn again and re-exporting fresh tokens. Third, check that ~/.agent_reach/config.yaml is readable and contains the linkedin: section at the root level. The doctor command in agent_reach/doctor.py specifically tests linkedin.check(), which validates cookie parsing and endpoint connectivity.

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 →