鉴权方式
同合云通过 API Key 鉴权。系统会直接读取请求头 Authorization 的原始值,并将它当作 API Key 校验。
标准写法
Authorization: YOUR_API_KEY
⚠️ 注意:这里没有
Bearer。如果你写成Authorization: Bearer YOUR_API_KEY,系统会把整串文本当作密钥,最终返回6502。
获取 API Key
- 登录 同合云官网。
- 进入 仪表盘。
- 在「API 密钥」区域点击 显示。
- 复制 API Key,并安全保存。
详细说明请参见 第一步:获取 API Key。
示例
cURL
curl -X POST https://api.ai-mcn.tv:10000/task/image_purify \
-H "Authorization: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"file_id": "537489015178246"
}'
Python
import requests
headers = {
"Authorization": "YOUR_API_KEY",
"Content-Type": "application/json",
}
response = requests.post(
"https://api.ai-mcn.tv:10000/task/image_purify",
headers=headers,
json={"file_id": "537489015178246"},
)
print(response.json())
JavaScript / TypeScript
const response = await fetch("https://api.ai-mcn.tv:10000/task/image_purify", {
method: "POST",
headers: {
Authorization: "YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({ file_id: "537489015178246" }),
});
console.log(await response.json());
可选的 Query 鉴权兜底
从代码实现看,服务端在显式开启环境变量 ALLOW_QUERY_AUTHORIZATION 时,也支持通过查询参数 Authorization 传递 API Key:
GET /task/list?Authorization=YOUR_API_KEY
ℹ️ 说明:这只是兜底能力,生产环境仍建议始终使用请求头。
鉴权失败响应
{
"code": 6502,
"msg": "鉴权失败,请检查Authorization参数",
"data": null
}