API 认证 —— JWT 令牌 // API

API 认证 —— JWT 令牌

OODA Intelligence 的 API 对所有请求均采用 JWT(JSON Web Tokens)认证。

获取令牌

向认证端点发起一次 POST 请求:

curl -X POST https://dashboard.oodaintel.com/api/v1/auth/token/ \
  -H "Content-Type: application/json" \
  -d '{"username": "您的用户名", "password": "您的密码"}'

响应

{
  "access": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...",
  "refresh": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..."
}

使用令牌

在所有请求的 Authorization 请求头中带上 access 令牌:

curl -X GET https://dashboard.oodaintel.com/api/v1/monitoring/ \
  -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..."

刷新令牌

access 令牌过期后,使用 refresh 令牌换取新的令牌:

curl -X POST https://dashboard.oodaintel.com/api/v1/auth/token/refresh/ \
  -H "Content-Type: application/json" \
  -d '{"refresh": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..."}'

速率限制

请求速率上限取决于所订阅的方案:

方案 上限
Starter 100 req/min
Professional 500 req/min
Enterprise 2.000 req/min

常见错误

状态码 说明
401 令牌无效或已过期
403 无权访问该资源
429 超出速率限制