ChatGPT 账号批量注册 + Codex Token 自动获取 + Token 池自动推送
基于 Python + Selenium 实现全流程自动化,内置 Web 管理面板,支持 5 个邮箱服务商、并行注册、Codex OAuth Token 自动获取,以及 CLIProxyAPI Token 池一键接入。
access_token / refresh_token# macOS / Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
# Windows (PowerShell)
irm https://astral.sh/uv/install.ps1 | iex
安装后需要将 ~/.local/bin 加入 PATH(macOS/Linux):
export PATH="$HOME/.local/bin:$PATH"
git clone https://github.com/your-username/gpt-auto-register.git
cd gpt-auto-register
uv sync
uv sync会自动安装 Python 3.13 和所有依赖,约需 30 秒。
cp config.example.yaml config.yaml
编辑 config.yaml,按需调整配置(默认值可直接使用)。
uv run python server.py
浏览器打开 http://localhost:8888 即可使用。
| 服务商 | 说明 | 默认启用 | 稳定性 |
|---|---|---|---|
| mail.tm | REST API,动态域名 | ✅ | ⭐⭐⭐ |
| GPTMail | mail.chatgpt.org.uk,Cookie+JWT | ✅ | ⭐⭐⭐ |
| TempMail.lol | api.tempmail.lol,纯 REST API | ✅ | ⭐⭐ |
| Temporam | temporam.com,Cookie 缓存 | ❌ | ⭐ |
| 2925 自有邮箱 | IMAP 收件箱 + alias | ❌ | 取决于配置 |
在 Web 面板「邮箱服务」区域可勾选/取消,或通过 API:
# 查看当前
curl -s http://localhost:8888/api/providers
# 启用全部
curl -X POST http://localhost:8888/api/providers \
-H 'Content-Type: application/json' \
-d '{"selected":["mailtm","gptmail","tempmail_lol"]}'
在 Web 面板「高级设置」→「代理设置」中配置,或通过 API:
curl -X POST http://localhost:8888/api/settings \
-H 'Content-Type: application/json' \
-d '{"proxy":{"enabled":true,"type":"http","host":"127.0.0.1","port":7897}}'
| 字段 | 说明 |
|---|---|
type |
http 或 socks5 |
host |
代理地址 |
port |
代理端口 |
use_auth |
是否需要认证 |
username / password |
认证信息(可选) |
注册成功后,Codex Token 可自动推送到 CLIProxyAPI 的 Token 池。
方式一:环境变量(推荐)
export CLIPROXY_API_URL="http://localhost:8317"
export CLIPROXY_API_KEY="your-management-password"
export CLIPROXY_AUTH_DIR="~/.cli-proxy-api"
uv run python server.py
方式二:写入 config.yaml
cliproxy:
enabled: true
api_url: "http://localhost:8317"
api_key: "your-management-password"
auth_dir: "~/.cli-proxy-api"
| 接口 | 方法 | 说明 |
|---|---|---|
/ |
GET | Web 管理面板 |
/api/status |
GET | 任务状态 + 日志 |
/api/start |
POST | 启动注册 {"count": N} |
/api/stop |
POST | 停止任务 |
/api/settings |
GET/POST | 代理 / 并行数 / Headless |
/api/providers |
GET/POST | 邮箱服务商选择 |
/api/accounts |
GET | 已注册账号列表 |
/api/token-import/start |
POST | 批量补取 Token |
data/
├── accounts/registered_accounts.txt # 已注册账号(邮箱|密码|时间|状态|凭证|提供商)
└── tokens/codex-*.json # Codex Token JSON
token_exports/<时间戳>/
├── ak.txt # access token(一行一个)
└── rk.txt # refresh token(一行一个)
不需要 Web 面板时可直接命令行运行:
uv run python main.py
通过 Web 面板「Token 导入」功能,或 API:
curl -X POST http://localhost:8888/api/token-import/start \
-H 'Content-Type: application/json' \
-d '{"accounts_file":"data/accounts/registered_accounts.txt","output_dir":"data/tokens"}'
完整配置字段见 config.example.yaml。
| 环境变量 | 对应配置 | 说明 |
|---|---|---|
CLIPROXY_API_URL |
cliproxy.api_url | CLIProxyAPI 地址 |
CLIPROXY_API_KEY |
cliproxy.api_key | CLIProxyAPI 管理密钥 |
CLIPROXY_AUTH_DIR |
cliproxy.auth_dir | Token 文件目录 |
OAUTH_ENABLED |
oauth.enabled | 是否获取 Codex Token |
OAUTH_REQUIRED |
oauth.required | Token 获取失败是否视为失败 |
CPA_UPLOAD_API_URL |
cpa.upload_api_url | CPA 上传地址 |
CPA_UPLOAD_API_TOKEN |
cpa.upload_api_token | CPA API Token |
CUSTOM2925_IMAP_PASSWORD |
custom2925.imap_password | 2925 IMAP 密码 |
├── app/ # 核心应用代码
│ ├── server.py # Web 服务(Flask + Waitress)
│ ├── main.py # 注册核心逻辑
│ ├── browser.py # 浏览器自动化(undetected-chromedriver)
│ ├── email_providers.py # 邮箱服务注册表
│ ├── mailtm_service.py # mail.tm 邮箱服务
│ ├── gptmail_service.py # GPTMail 邮箱服务
│ ├── tempmail_lol_service.py # TempMail.lol 邮箱服务
│ ├── temporam_service.py # Temporam 邮箱服务
│ ├── custom2925_service.py # 2925 自有邮箱服务
│ ├── oauth_service.py # Codex OAuth + Token 保存 + CLIProxy 推送
│ ├── token_batch_service.py # 批量 Token 补取
│ ├── stored_accounts.py # 账号存储管理
│ ├── config.py # 配置加载
│ └── utils.py # 工具函数
├── scripts/
│ └── get_codex_token.py # 为已有账号单独补取 token
├── static/ # 前端资源
│ ├── index.html
│ ├── style.css
│ └── script.js
├── tests/ # 测试
├── server.py # Web 启动入口
├── main.py # CLI 启动入口
├── config.example.yaml # 配置模板
├── pyproject.toml # 依赖定义
└── LICENSE # MIT License
config.yaml 包含个人配置,已加入 .gitignore本工具仅供教育机构内部使用,旨在辅助老师和学生快速开通 ChatGPT 账号用于教学和学习。使用者应遵守 OpenAI 的使用条款,并自行承担使用本工具产生的任何后果。
本项目基于以下开源项目二次开发:
$ claude mcp add gpt-auto-register \
-- python -m otcore.mcp_server <graph>