CLI 功能命令通常需要先完成认证。你可以使用 API Key、OAuth、stdin 或环境变量登录。
认证说明
需要认证的操作包括:列出任务、网页 detect、本地 / 云端运行、--task-file 本地运行、数据历史与导出等。
无需认证即可运行的诊断命令包括:
octopus --help
octopus --version
octopus capabilities
octopus doctor
octopus browser doctor
octopus auth
创建 API Key
在八爪鱼账户中心 创建 API Key,复制并妥善保存。Key 通常只显示一次。
请勿将 API Key 写入 Git 仓库、公开脚本、文档截图、共享日志或 CI 输出。
登录方式
交互式登录
交互式登录会引导你选择 OAuth 或 API Key 登录方式。
OAuth 登录
octopus auth login --oauth
适合可打开浏览器的桌面环境。
直接传入 API Key
octopus auth login <你的APIKey>
从 stdin 读取
适合 CI/CD 或密钥管理系统:
echo <你的APIKey> | octopus auth login --stdin
不自动打开浏览器
octopus auth login --no-open
适合无 GUI 服务器或需要手动复制授权地址的环境。
环境变量
# Windows PowerShell
$env:OCTOPUS_API_KEY="你的APIKey"
octopus task list --json
# Linux / macOS
OCTOPUS_API_KEY=你的APIKey octopus task list --json
如果你使用 Access Token:
OCTOPUS_ACCESS_TOKEN=你的AccessToken octopus task list --json
私有化或代理环境可覆盖 API 地址:
octopus task list --api-base-url https://example.com --json
凭据优先级
CLI 会优先读取环境变量,其次读取本地凭据文件:
1. OCTOPUS_ACCESS_TOKEN / OCTOPUS_API_KEY
2. 本地凭据文件 ~/.octoparse/credentials.json
octopus auth login 会自动创建本地凭据文件。默认路径:
| 系统 | 路径 |
|---|
| Windows | %USERPROFILE%\.octoparse\credentials.json |
| macOS / Linux | ~/.octoparse/credentials.json |
查看与退出登录
octopus auth status
octopus auth status --json
octopus auth logout
下一步
运行第一个任务
从新 URL 快速采集,或运行已有任务。