From 9ab71b7761b20681f469e7c88a982ab87d695b12 Mon Sep 17 00:00:00 2001 From: Ozan Boz Date: Fri, 11 Sep 2026 01:04:18 +0300 Subject: [PATCH] fix(auth): find cookies in Chromium, not just Chrome MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit browser_cookie3.chromium was missing from both extraction paths, so `rdt login` failed with "No Reddit cookies found" on systems whose browser is Chromium rather than Chrome — the default on Arch, Omarchy and other distros — even with a valid logged-in session. The subprocess path also broke on the first browser that returned *any* cookie, so a browser holding only tracking cookies (csv, edgebucket) shadowed the one that actually had reddit_session; the caller then rejected the result and reported "no cookies found". It now breaks on REQUIRED_COOKIES, matching _extract_direct. Net -3 lines: the accumulate-then-check dance is gone, and `import browser_cookie3 as bc` keeps the longer browser list on one line. --- rdt_cli/auth.py | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/rdt_cli/auth.py b/rdt_cli/auth.py index 9573e95..29b0c5f 100644 --- a/rdt_cli/auth.py +++ b/rdt_cli/auth.py @@ -137,21 +137,18 @@ def extract_browser_credential() -> Credential | None: def _extract_subprocess() -> Credential | None: """Extract via uv subprocess — avoids SQLite lock.""" - script = ''' -import browser_cookie3, json -cookies = {} -for browser_fn in [browser_cookie3.chrome, browser_cookie3.firefox, browser_cookie3.edge, browser_cookie3.brave]: + script = f""" +import browser_cookie3 as bc, json +required = {sorted(REQUIRED_COOKIES)!r} +for browser_fn in [bc.chrome, bc.chromium, bc.firefox, bc.edge, bc.brave]: try: - jar = browser_fn(domain_name=".reddit.com") - for c in jar: - cookies[c.name] = c.value - if cookies: - break + cookies = {{c.name: c.value for c in browser_fn(domain_name=".reddit.com")}} except Exception: continue -if cookies: - print(json.dumps(cookies)) -''' + if any(k in cookies for k in required): + print(json.dumps(cookies)) + break +""" try: result = subprocess.run( ["uv", "run", "--with", "browser-cookie3", "python3", "-c", script], @@ -173,12 +170,12 @@ def _extract_subprocess() -> Credential | None: def _extract_direct() -> Credential | None: """Fallback direct extraction (may fail if browser is open).""" try: - import browser_cookie3 + import browser_cookie3 as bc except ImportError: logger.warning("browser-cookie3 not available for direct extraction") return None - for fn in [browser_cookie3.chrome, browser_cookie3.firefox, browser_cookie3.edge, browser_cookie3.brave]: + for fn in [bc.chrome, bc.chromium, bc.firefox, bc.edge, bc.brave]: try: jar = fn(domain_name=".reddit.com") cookies = {c.name: c.value for c in jar}