keytoauth
一个自动icloud取码到登录chatgpt取auth session最后转cpa+sub2api的脚本
A Python automation script that logs in to ChatGPT accounts using activation key codes, retrieves one-time email codes via an API, and saves the resulting session credentials in two output formats.
This is a Python script that automates the process of logging in to ChatGPT accounts using activation key codes and extracting the resulting session credentials. Given a list of keys, the tool uses a headless browser to visit the ChatGPT login page, retrieve a one-time verification code from an email API, complete the login flow, and then save the extracted session data in two formats: CPA (for use with CLIProxyAPI) and Sub2API.
The README is written in Chinese and describes a pipeline involving several components: the Patchright browser library (a modified version of Playwright for Chrome), a locally running FlareSolverr instance to handle Cloudflare protection on the ChatGPT login page, a mail server API that retrieves verification codes, and an optional CLIProxyAPI management server to skip accounts that already have valid sessions.
Typical usage involves providing a text file of keys, one per line, and running the script. The tool works through each key in sequence, opens a browser window, fills in the email address tied to that key, waits for a one-time code from the email API, submits it, and once logged in extracts the session JSON from the ChatGPT API endpoint. Output files are written to an output folder named after each account email address.
The project includes support for proxy connections (HTTP, HTTPS, SOCKS4, SOCKS5) routed through both the browser and FlareSolverr. Configurable wait times help the script stay stable on slow proxy connections. Logs, screenshots, and HTML snapshots are saved on failure to help with debugging.
The codebase is small, consisting of a few Python modules for API calls, browser automation, configuration, session conversion, and a command-line entry point. Tests for helper functions are included.
Where it fits
- Batch-process a list of ChatGPT activation keys to extract usable session credentials without manual login steps.
- Export ChatGPT session tokens into CPA or Sub2API format for use with downstream API proxy tooling.
- Route headless browser login sessions through SOCKS5 or HTTP proxies to reduce IP-based blocks during automation.