认证与授权错误
以下错误码在认证与授权阶段返回。
| HTTP 状态码 | 业务码 | 说明 |
|---|---|---|
| 401 | AUTH_REQUIRED | 缺少 Authorization 请求头 |
| 401 | AUTH_INVALID | 认证信息无效 |
| 401 | AUTH_EXPIRED | access token 已过期 |
| 403 | AUTH_SCOPE_DENIED | 当前客户端没有访问该接口所需权限 |
权限不足响应
AUTH_SCOPE_DENIED 会返回当前操作要求的权限。
json
{
"code": "AUTH_SCOPE_DENIED",
"message": "This operation requires the device:control permission. Update the API Client permissions in the Developer Console and obtain a new access token.",
"requestId": "req_001",
"data": {
"requiredScope": "device:control"
}
}收到该错误后:
- 在开发者后台为 API Client 增加
data.requiredScope指定的权限。 - 保存权限配置。
- 重新获取 access token。
- 使用新 token 重试原操作。
例如只有 device:read 权限时执行继电器开关,会提示需要 device:control。
