{"record":{"id":"abace13cc1668cf4","repo":"Panniantong/Agent-Reach","slug":"x-could-not-find-auth-token-and-ct0-in-your-inpu","errorCode":null,"errorMessage":"[X] Could not find auth_token and ct0 in your input.","messagePattern":"\\[X\\] Could not find auth_token and ct0 in your input\\.","errorType":"console","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"agent_reach/cli.py","lineNumber":1515,"sourceCode":"                \"  凭据未实时验证：不会执行 `twitter status`，因为上游在\"\n                \"验证失败时会自动读取浏览器 Cookie。\"\n            )\n            if not shutil.which(\"twitter\"):\n                print(\n                    \"  [!] twitter-cli 未安装。运行：pipx install twitter-cli\"\n                )\n            else:\n                print(\n                    \"  注意：独立 `twitter` 命令不会读取 Agent Reach 配置；\"\n                    \"直接使用时需显式设置 TWITTER_AUTH_TOKEN/TWITTER_CT0。\"\n                )\n        else:\n            print(\"[X] Could not find auth_token and ct0 in your input.\")\n            print(\"   Run `agent-reach configure twitter-cookies` and paste either:\")\n            print(\"   1. AUTH_TOKEN and CT0 separated by whitespace\")\n            print(\"   2. A Cookie-Editor Header String\")\n            print(\"   For automation, pass the same value through --stdin.\")\n            raise SystemExit(1)\n\n    elif args.key == \"youtube-cookies\":\n        config.set(\"youtube_cookies_from\", value)\n        print(f\"✅ YouTube cookie source configured: {value}\")\n        print(\"   yt-dlp will use cookies from this browser for age-restricted/member videos.\")\n\n    elif args.key == \"xhs-cookies\":\n        if not _configure_xhs_cookies(value):\n            raise SystemExit(1)\n\n    elif args.key == \"github-token\":\n        config.set(\"github_token\", value)\n        print(\"✅ GitHub token configured!\")\n\n    elif args.key == \"groq-key\":\n        config.set(\"groq_api_key\", value)\n        print(\"✅ Groq key configured!\")\n","sourceCodeStart":1497,"sourceCodeEnd":1533,"githubUrl":"https://github.com/Panniantong/Agent-Reach/blob/93ae1d18c37b707dec053c7c4f9d91cd8ef8943d/agent_reach/cli.py#L1497-L1533","documentation":"For `agent-reach configure twitter-cookies`, the CLI parses the pasted value expecting either 'AUTH_TOKEN CT0' separated by whitespace or a Cookie-Editor Header String containing both auth_token and ct0 cookies. If neither token can be extracted, it prints this error with the accepted formats and exits 1.","triggerScenarios":"Pasting only one of the two tokens (auth_token without ct0), a Cookie-Editor export in JSON format instead of 'Header String' format, a header string from a different domain, or a value where the token names are misspelled. Automation hits it when piping a malformed string via --stdin.","commonSituations":"Users exporting cookies with the Cookie-Editor extension but clicking 'JSON' instead of 'Header String'; expired logged-out sessions where auth_token is absent; pasting from a note app that mangles separators; per CLAUDE.md, QR-scan logins for X are unsupported — only Cookie-Editor exports are.","solutions":["In the Cookie-Editor extension on x.com, choose Export → 'Header String' (not JSON) and re-run: agent-reach configure twitter-cookies --stdin","Or paste exactly two whitespace-separated values: <auth_token> <ct0>","Confirm you are actually logged in to x.com in that browser (both cookies exist) before exporting","For automation, generate the 'auth_token=...; ct0=...' header string programmatically and pipe it via --stdin"],"exampleFix":"# before: JSON export (unsupported)\ncat cookies.json | agent-reach configure twitter-cookies --stdin\n\n# after: header-string export (supported)\n# Cookie-Editor → Export → Header String, then:\nagent-reach configure twitter-cookies --stdin <<< 'auth_token=ABC123; ct0=XYZ789'","handlingStrategy":"validation","validationCode":"import re\n\ndef looks_like_twitter_cookies(value: str) -> bool:\n    if re.search(r\"auth_token=[^;\\s]+\", value) and re.search(r\"\\bct0=[^;\\s]+\", value):\n        return True  # Cookie-Editor header string\n    parts = value.split()\n    return len(parts) == 2 and all(re.fullmatch(r\"[A-Za-z0-9]{20,}\", p) for p in parts)\n\nassert looks_like_twitter_cookies(value), \"need 'auth_token=..; ct0=..' header string or 'AUTH_TOKEN CT0' pair\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always export via Cookie-Editor → 'Header String'; JSON exports are not accepted","Verify you are logged in on x.com before exporting (both auth_token and ct0 must exist)","In automation, build the 'auth_token=...; ct0=...' string yourself and pipe it via --stdin"],"tags":["cli","configure","twitter","cookies","parsing","exit-code-1"],"backgroundTag":null,"analyzedSha":"93ae1d18c37b707dec053c7c4f9d91cd8ef8943d","analyzedAt":"2026-08-14T22:54:06.735Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}