cbi-shared
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCreatiBI CLI 基础配置与认证
CreatiBI CLI Basic Configuration and Authentication
CreatiBI 命令行工具的初始化与认证模块。
Initialization and authentication module of the CreatiBI command-line tool.
安装
Installation
bash
undefinedbash
undefinednpm 安装(推荐)
npm installation (recommended)
npm install -g @creatibi/cbi-cli@latest
npm install -g @creatibi/cbi-cli@latest
或使用 npx(无需安装)
Or use npx (no installation required)
npx @creatibi/cbi-cli --help
支持平台:macOS (amd64/arm64)、Linux (amd64/arm64)、Windows (amd64/arm64)
---npx @creatibi/cbi-cli --help
Supported platforms: macOS (amd64/arm64), Linux (amd64/arm64), Windows (amd64/arm64)
---快速开始
Quick Start
bash
undefinedbash
undefined1. 初始化配置(首次使用)
1. Initialize configuration (for first use)
cbi config init
cbi config init
2. OAuth 登录
2. OAuth login
cbi auth login
cbi auth login
3. 确认登录成功
3. Confirm login success
cbi auth whoami
---cbi auth whoami
---常用命令速查
Quick Reference for Common Commands
| 场景 | 命令 |
|---|---|
| 初始化配置 | |
| 强制重新初始化 | |
| 查看配置 | |
| 登录授权 | |
| 查看身份 | |
| 退出登录 | |
| Scenario | Command |
|---|---|
| Initialize configuration | |
| Force re-initialization | |
| View configuration | |
| Login authorization | |
| Check current identity | |
| Logout | |
配置模块 (config)
Configuration Module (config)
初始化配置
Initialize Configuration
首次使用需要初始化应用凭证配置:
bash
undefinedInitialization of application credential configuration is required for first use:
bash
undefined初始化配置(交互式输入)
Initialize configuration (interactive input)
cbi config init
cbi config init
强制重新初始化(覆盖已有配置)
Force re-initialization (overwrite existing configuration)
cbi config init --new
**流程:**
1. 检查配置是否已存在
2. 若已存在,需使用 `--new` 强制覆盖
3. 引导输入应用凭证信息:
- `client_id`(应用 ID)- 必填
- `client_secret`(应用密钥)- 必填
- `base_url`(默认 https://open.creatibi.cn)
- `default_workspace`(可选)
4. 配置写入 `~/.cbi/config.json`
**前提条件:** 在 CreatiBI 开放平台创建应用,获取 client_id 和 client_secretcbi config init --new
**Process:**
1. Check if configuration already exists
2. If it exists, use `--new` to force overwrite
3. Guide users to enter application credential information:
- `client_id` (Application ID) - Required
- `client_secret` (Application Secret) - Required
- `base_url` (default https://open.creatibi.cn)
- `default_workspace` (optional)
4. Configuration is written to `~/.cbi/config.json`
**Prerequisite:** Create an application on the CreatiBI Open Platform to obtain client_id and client_secret显示当前配置
Show Current Configuration
bash
cbi config show # 显示配置(敏感字段脱敏)
cbi config show -v # 详细模式(显示登录凭证)
cbi config show --format json # JSON 格式输出bash
cbi config show # Show configuration (sensitive fields desensitized)
cbi config show -v # Verbose mode (show login credentials)
cbi config show --format json # Output in JSON format认证模块 (auth)
Authentication Module (auth)
OAuth 登录
OAuth Login
bash
cbi auth login前提条件: 已执行 配置应用凭证
cbi config init流程:
- CLI 启动本地回调服务器(端口 8080)
- 自动打开浏览器访问授权页面
- 用户在浏览器中完成授权
- 服务端回调到 CLI 并返回授权码
- CLI 用授权码换取 access_token
- Token 存储在 ~/.cbi/config.json
bash
cbi auth loginPrerequisite: Executed to configure application credentials
cbi config initProcess:
- CLI starts a local callback server (port 8080)
- Automatically opens the browser to access the authorization page
- Users complete authorization in the browser
- The server callbacks to the CLI and returns an authorization code
- CLI exchanges the authorization code for access_token
- Token is stored in ~/.cbi/config.json
查看当前身份
Check Current Identity
bash
cbi auth whoami # 查看当前登录身份
cbi auth whoami -v # 详细模式(显示 token 信息)bash
cbi auth whoami # Check current logged-in identity
cbi auth whoami -v # Verbose mode (show token information)退出登录
Logout
bash
cbi auth logoutbash
cbi auth logout错误处理
Error Handling
权限不足/未登录
Insufficient Permissions/Not Logged In
当遇到 或 错误时:
permission deniedauth requiredbash
undefinedWhen encountering or errors:
permission deniedauth requiredbash
undefined1. 检查配置是否存在
1. Check if configuration exists
cbi config show
cbi config show
2. 如果配置不存在,先初始化
2. If configuration does not exist, initialize first
cbi config init
cbi config init
3. 登录授权
3. Login authorization
cbi auth login
cbi auth login
4. 确认登录成功
4. Confirm login success
cbi auth whoami
undefinedcbi auth whoami
undefinedToken 过期
Token Expired
当遇到 错误时:
expired access tokenbash
cbi auth login # 重新登录When encountering errors:
expired access tokenbash
cbi auth login # Log in again配置文件问题
Configuration File Issues
bash
cbi config init --new # 强制重新初始化配置
cbi auth login # 重新登录bash
cbi config init --new # Force re-initialization of configuration
cbi auth login # Log in again配置文件位置
Configuration File Location
配置存储在 :
~/.cbi/config.jsonjson
{
"base_url": "https://open.creatibi.cn",
"client_id": "YOUR_CLIENT_ID",
"client_secret": "YOUR_CLIENT_SECRET",
"api_key": "YOUR_ACCESS_TOKEN",
"refresh_token": "YOUR_REFRESH_TOKEN",
"token_expires_at": "2026-04-24T00:28:54Z"
}Configuration is stored in :
~/.cbi/config.jsonjson
{
"base_url": "https://open.creatibi.cn",
"client_id": "YOUR_CLIENT_ID",
"client_secret": "YOUR_CLIENT_SECRET",
"api_key": "YOUR_ACCESS_TOKEN",
"refresh_token": "YOUR_REFRESH_TOKEN",
"token_expires_at": "2026-04-24T00:28:54Z"
}通用参数
General Parameters
| 参数 | 说明 |
|---|---|
| 配置文件路径(默认 ~/.cbi/config.json) |
| 输出格式:json / table |
| 显示详细信息 |
| Parameter | Description |
|---|---|
| Configuration file path (default ~/.cbi/config.json) |
| Output format: json / table |
| Show detailed information |