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

提供者憑證和連接

註冊 IMAP/SMTP 憑證、驗證連線並維護憑證生命週期。

inbox-manager client-flow

提供者憑證和連接

目的:註冊 IMAP/SMTP 憑證、驗證連線並維護憑證生命週期。

使用者介面流程

  1. 使用者輸入 IMAP 和 SMTP 主機/連接埠/安全模式和機密值。
  2. UI 使用POST /api/accounts/:account_id/provider-credentials 建立憑證。
  3. UI 立即使用POST /api/provider-credentials/:provider_credential_id/test 進行驗證。
  4. UI 列出憑證和驗證狀態。
  5. UI 支援旋轉 (/rotate) 和刪除以確保憑證衛生。

客戶端庫流程

const imapCredential = await api.credentials.create(accountId, {
  provider_kind: "imap",
  label: "Work IMAP",
  host: "mail.example.com",
  port: 993,
  security_mode: "ssl_tls",
  auth_kind: "password",
  secret: { username, password },
});
await api.credentials.test(imapCredential.data.id);

HTTP/curl 流程

API_BASE_URL="https://api.inbox-manager.com"

curl -sS -X POST "${API_BASE_URL}/api/accounts/${ACCOUNT_ID}/provider-credentials" \
  -H "authorization: Bearer ${BEARER_TOKEN}" \
  -H "content-type: application/json" \
  --data '{
    "provider_kind":"imap",
    "label":"Work IMAP",
    "host":"mail.example.com",
    "port":993,
    "security_mode":"ssl_tls",
    "auth_kind":"password",
    "secret":{"username":"user@example.com","password":"***"}
  }'

curl -sS -X POST "${API_BASE_URL}/api/provider-credentials/${PROVIDER_CREDENTIAL_ID}/test" \
  -H "authorization: Bearer ${BEARER_TOKEN}"

curl -sS -X POST "${API_BASE_URL}/api/provider-credentials/${PROVIDER_CREDENTIAL_ID}/rotate" \
  -H "authorization: Bearer ${BEARER_TOKEN}" \
  -H "content-type: application/json" \
  --data '{"secret":{"username":"user@example.com","password":"***"}}'

驗證腳本

  • scripts/provider_credentials_flow.sh