获取 API 密钥
身份验证

POST /api/auth/sessions/exchange

POST https://api.iagenify.com/api/auth/sessions/exchange

交换a API 用于无记名会话的密钥。在受保护的状态下使用返回的无记名牌 API 请求并只将刷新牌保存在可信任的服务器端存储中。

无需 Bearer 令牌JSON会话交换

HTTP 请求

curl https://api.iagenify.com/api/auth/sessions/exchange \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{"apiKey":"YOUR_API_KEY"}'

JavaScript

const response = await fetch("https://api.iagenify.com/api/auth/sessions/exchange", {
  method: "POST", headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ apiKey: process.env.IAGENIFY_API_KEY }),
});
const session = await response.json();
if (!response.ok) throw new Error(session.error);
// Store session.jwt and session.refreshToken only in trusted storage.

Python

import os, requests

response = requests.post(
    "https://api.iagenify.com/api/auth/sessions/exchange",
    json={"apiKey": os.environ["IAGENIFY_API_KEY"]},
    timeout=30,
)
response.raise_for_status()
session = response.json()

请求体

apiKeystring必填

下 API 键交换。

storageIdstring

任择储存协会。

storageTypestring

客户可选存储类型。

frameworkstring

可选客户框架标签。

appNamestring

任择申请姓名。

成功响应

{
  ok: true,
  jwt: "…",
  refreshToken: "…",
  session: { id: "…", storageId: "…" }
}

下个请求

发送返回 JWT 年为 Authorization: Bearer YOUR_JWT。当它过期时,使用 POST /api/auth/refresh; 从来没有在 URL 或浏览器发送源。