调用 WeKnora 原子化接口 POST /api/v1/chat/completions 时,按官方文档签名仍返回INVALID_SIGNATURE。
文档规则:
signature = HMAC-SHA256(Secret-Key, timestamp + "\n" + nonce + "\n" + request_id + "\n" + request_body)
请求信息:
Base URL: https://weknora.weixin.qq.com/api/v1
Path: /chat/completions
Method: POST
Content-Type: application/json
X-APPID: app-xxx-xxxx-xxxxx
X-Request-ID: K80bMxI4Y9ik
X-Timestamp: 当前秒级时间戳
X-Nonce: 自定义字符串
Secret-Key: 平台 openapi 页面获取,已脱敏
request_body 使用实际发送的紧凑 JSON:
{"model":"chat","messages":[{"role":"user","content":"你好,请简单介绍一下你自
己"}],"stream":false,"max_tokens":128,"temperature":0.2}
返回:
{
"error": {
"code": "INVALID_SIGNATURE",
"message": "签名验证失败",
"detail": "签名不匹配,期望为32位十六进制值,实际为64位十六进制值"
}
}
请问:
1. X-Signature 是否应使用 HMAC-SHA256 的 hex 输出?
2. request_body 是否必须紧凑 JSON,是否需要字段排序?
3. 签名串是否还需要包含 method、path 或 query?
4. 是否有官方 Python 签名示例?

您好 WeKnora原子能力接口示例参考文档。
参考文档:https://developers.weixin.qq.com/doc/aispeech/knowledge/atomic_capability/atomic_interface.html
参考文档:https://developers.weixin.qq.com/doc/aispeech/knowledge/atomic_capability/atomic_interface.html
也遇到了相同问题,傻逼官方,傻逼文档
参考文档:https://developers.weixin.qq.com/doc/aispeech/knowledge/atomic_capability/atomic_interface.html
1. 不是,当前报错说明服务端要的是32位十六进制签名,不接受64位SHA256 hex。 2. request_body要和实际发送的原始JSON完全一致,建议紧凑化,字段顺序也要一致。 3. 不包含 method、path、query,按文档只拼 timestamp、nonce、request_id、request_body。 4. 不知道官方是否有 Python 示例
参考文档:https://developers.weixin.qq.com/doc/aispeech/knowledge/atomic_capability/atomic_interface.html