openclaw WebSocket 认证请求格式
platform : 运行平台,如 "win32"、"linux" 等。- id : 客户端 ID,固定为 "gateway-client"- scopes : 权限范围,包含 "operator.admin"3. method : 固定为 "connect",表示这是一个连接请求。- version : 客户端版本,固定为 "dev"- mode : 运行模式,固定为 "backend"- ro
完整的 WebSocket 认证请求格式,如下所示:
{
"type": "req",
"id": "connect-" + Date.now(),
"method": "connect",
"params": {
"minProtocol": 3,
"maxProtocol": 3,
"client": {
"id": "gateway-client",
"version": "dev",
"platform": process.platform,
"mode": "backend",
"instanceId": "test-instance-" + Date.now()
},
"role": "operator",
"scopes": ["operator.admin"],
"caps": [],
"auth": {
"token": "填写实际webUI-token"
}
}
}
## 关键字段说明
1. type : 固定为 "req",表示这是一个请求
2. id : 唯一请求 ID,通常使用时间戳生成
3. method : 固定为 "connect",表示这是一个连接请求
4. params : 包含连接参数的对象
- minProtocol/maxProtocol : 协议版本范围,当前为 3
- client : 客户端信息
- id : 客户端 ID,固定为 "gateway-client"
- version : 客户端版本,固定为 "dev"
- platform : 运行平台,如 "win32"、"linux" 等
- mode : 运行模式,固定为 "backend"
- instanceId : 实例 ID,通常使用时间戳生成
- role : 角色,固定为 "operator"
- scopes : 权限范围,包含 "operator.admin"
- caps : 客户端能力,为空数组
- auth : 认证信息
- token : 认证令牌,从配置文件中获取
## 认证流程
1. 客户端建立 WebSocket 连接
2. 服务器发送 connect.challenge 事件,包含 nonce
3. 客户端提取 nonce ,并使用上述格式发送连接请求
4. 服务器验证认证信息,返回连接结果
5. 连接成功后,客户端可以发送其他请求,如搜索请求
更多推荐

所有评论(0)