openclaw devices

管理设备配对请求和设备级 token(轮换/撤销)。

常用命令

openclaw devices list                    # 列出 pending 请求和已配对设备
openclaw devices list --json
openclaw devices approve <requestId>     # 审批配对请求(需明确 requestId)
openclaw devices approve --latest        # 仅预览最新 pending 请求,不审批
openclaw devices reject <requestId>      # 拒绝配对请求
openclaw devices remove <deviceId>       # 删除单个配对记录
openclaw devices clear --yes             # 批量清除已配对设备
openclaw devices clear --yes --pending   # 同时清除 pending 请求

Token 轮换与撤销

# 轮换 token(可更新 scope)
openclaw devices rotate --device <deviceId> --role operator --scope operator.read --scope operator.write
 
# 撤销 token
openclaw devices revoke --device <deviceId> --role node

权限规则:

  • 非 admin 的配对设备 token 只能操作自己的 token
  • 跨设备管理需要 operator.admin
  • 轮换/撤销不能超出调用方自身的 operator scope

rotate 返回 JSON 元数据;若调用方正在轮换自己的 token,响应中包含新 token(需持久化)。

审批注意事项

  • 审批前必须提供明确的 requestId,省略或使用 --latest 仅预览
  • 设备重试配对时(role/scopes/公钥变更),旧 pending 请求被替换,产生新 requestId,审批前需重新 list
  • 已配对设备申请更广 scope 时,旧审批保留,新建 upgrade pending 请求

Token 漂移恢复

遇到 AUTH_TOKEN_MISMATCH / AUTH_DEVICE_TOKEN_MISMATCH / AUTH_SCOPE_MISMATCH 时:

# 1. 确认当前 token 来源
openclaw config get gateway.auth.token
 
# 2. 列出设备,找到问题设备 ID
openclaw devices list
 
# 3. 轮换 token
openclaw devices rotate --device <deviceId> --role operator
 
# 4. 若轮换不够,删除配对后重新审批
openclaw devices remove <deviceId>
openclaw devices approve <requestId>

通用选项

  • --url <url>:Gateway WebSocket URL
  • --token <token>:Gateway token
  • --password <password>:密码认证
  • --timeout <ms>:RPC 超时
  • --json:JSON 输出(推荐脚本使用)

相关链接