Skip to content

fix: use curl_cffi with Chrome impersonation to avoid 403 from Reddit - #24

Closed
ghost wants to merge 1 commit into
mainfrom
unknown repository
Closed

ghost wants to merge 1 commit into
mainfrom
unknown repository

Conversation

@ghost

@ghost ghost commented Oct 8, 2026

Copy link
Copy Markdown

Problem

rdt status and every read command (rdt feed, etc.) fail with
Access forbidden: Resource (HTTP 403), even right after rdt login
with valid browser cookies. A plain curl to https://www.reddit.com/
from the same machine also returns 403, while the site works normally
in Chrome.

Cause

Reddit rejects clients whose TLS fingerprint does not look like a real
browser. httpx is rejected regardless of headers, User-Agent or cookies.

Fix

Use curl_cffi with impersonate="chrome" in rdt_cli/transports.py
instead of httpx, and add curl_cffi to the dependencies.

  • httpx.Client -> curl_cffi.requests.Session(impersonate="chrome")
  • httpx.TimeoutException / httpx.NetworkError -> curl_cffi's
    Timeout / ConnectionError
  • The rest of the response/cookie handling is unchanged (same
    status_code, headers, text, json() and cookies API)

Testing

  • Before: rdt status -> "Not authenticated, Access forbidden"
  • After: rdt status -> "Authenticated", capabilities: read, write
  • Unit tests: 123 passed
  • Smoke tests (live cookies): 60 passed, 4 skipped, 2 failed.
    The 2 failures (test_status_yaml, test_sub_info_yaml) assert the
    literal text ok: true, but the YAML output is tagged
    ("ok": !!bool "true"). The requests themselves succeed, so this is
    unrelated to the HTTP client change.
  • ruff check passes. ruff format --check already reports 7 files
    on the base branch; transports.py is clean.
  • Tested on Ubuntu, Python 3.14, curl_cffi 0.16.3

Notes

This 403 may depend on the environment (network/TLS fingerprint), so it
may not affect every user. Impersonating Chrome should be harmless for
those it does not affect.

Reddit rejects requests whose TLS fingerprint does not match a real
browser, returning 403 regardless of cookies or User-Agent. Replace
httpx with curl_cffi (impersonate="chrome") in the transports.
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant