IM
ZH-TW
文件首頁
選單
指南

身份驗證和令牌引導程式

在呼叫收件匣管理員 API 之前取得不記名令牌並驗證驗證端點行為。

inbox-manager client-flow

身份驗證和令牌引導程式

目的:在呼叫收件匣管理員 API 之前取得不記名令牌並驗證驗證端點行為。

邊界註:

  • 此流程呼叫auth.inbox-manager.com端點。
  • 這些路線不是api.inbox-manager.com OpenAPI 的一部分。

使用者介面流程

  1. 使用者開啟註冊表單或登入表單。
  2. UI 將憑證提交至https://auth.inbox-manager.com/auth/sign-up/auth/sign-in
  3. UI 儲存傳回的存取令牌和帳戶上下文。
  4. UI 在需要時透過 POST /api/accounts/:account_id/token 請求帳戶範圍的令牌。
  5. UI 使用傳回的令牌作為Authorization: Bearer <token> 代表api.inbox-manager.com

客戶端庫流程

const auth = new AuthClient({ baseUrl: "https://auth.inbox-manager.com" });
const session = await auth.signIn({
  email,
  password,
  clientId: "cid_inbox_manager",
});
const accountToken = await auth.issueAccountToken({
  accountId: session.profile.active_membership.account_id,
  bearerToken: session.tokens.access_token,
  audience: "https://api.inbox-manager.com",
});
const api = new InboxManagerClient({
  baseUrl: "https://api.inbox-manager.com",
  bearerToken: accountToken.access_token,
});

HTTP/curl 流程

AUTH_BASE_URL="https://auth.inbox-manager.com"
ORIGIN="https://app.inbox-manager.com"
CLIENT_ID="cid_inbox_manager"

curl -sS "${AUTH_BASE_URL}/.well-known/jwks.json"

curl -sS -X POST "${AUTH_BASE_URL}/auth/sign-in" \
  -H "origin: ${ORIGIN}" \
  -H "content-type: application/json" \
  --data "{\"client_id\":\"${CLIENT_ID}\",\"email\":\"${EMAIL}\",\"password\":\"${PASSWORD}\",\"csrf_token\":\"${CSRF_TOKEN}\"}"

curl -sS -X POST "${AUTH_BASE_URL}/api/accounts/${ACCOUNT_ID}/token" \
  -H "authorization: Bearer ${ACCESS_TOKEN}" \
  -H "content-type: application/json" \
  --data '{"audience":"https://api.inbox-manager.com"}'

驗證腳本

  • scripts/auth_probe.sh -scripts/auth_bootstrap_accounts.sh