diff --git a/.gitignore b/.gitignore index 0e7f077..9aeb399 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ node_modules/ .env .DS_Store *.txt -AGENTS.md \ No newline at end of file +AGENTS.md +accounts.json \ No newline at end of file diff --git a/README.md b/README.md index 8ad6254..e13dd42 100644 --- a/README.md +++ b/README.md @@ -78,8 +78,49 @@ export DROID_REFRESH_KEY="your_refresh_token_here" # 方式4:无配置(客户端授权) # 服务器将使用客户端请求头中的authorization字段 + +# 方式5:多账号OAuth(推荐免费用户) +# 使用 accounts.json 配置多个账号自动轮询 ``` +### 多账号 OAuth 支持(推荐) + +适用于免费账号用户,支持多个账号自动轮询: + +**1. 添加账号** + +```bash +# 交互式添加账号(自动打开浏览器完成授权) +node add-account.js + +# 连续添加多个账号 +node add-account.js --loop +``` + +**2. 同步到远程服务器** + +```bash +# 配置 .env 中的同步参数 +SYNC_SERVER=user@your-server.com +SYNC_REMOTE_PATH=/opt/droid2api +DEPLOY_TYPE=docker-compose + +# 运行同步脚本 +./sync-accounts.sh +``` + +**3. 配置优先级** + +``` +accounts.json (多账号OAuth) > FACTORY_API_KEY > DROID_REFRESH_KEY > ~/.factory/auth.json +``` + +**4. 账号管理特性** +- ✅ 基于健康度加权轮询选择账号 +- ✅ 自动刷新 access_token(每6小时) +- ✅ 401/402 错误时自动禁用异常账号 +- ✅ 请求统计和健康度监控 + ### 2. 配置模型(可选) 编辑 `config.json` 添加或修改模型: