生成 TOTP 密鑰
POST /v1/security/totp/generate:為用戶產生新的 TOTP 密鑰,供其加入驗證器應用程式。
POST /v1/security/totp/generate
為用戶產生新的 TOTP 密鑰,供其加入驗證器應用程式:qrCodeUrl 是 otpauth:// 連結,qrcode 是預先渲染的 PNG data URL,secret 是供手動輸入的 base32 字串。不返回備份碼。它是設定 → 安全啟用嚮導的第 2 步,也是替換現有綁定的調用:仍持有密鑰的帳戶可以改用目前的驗證器重新開啟。
| 方法 | POST |
| 路徑 | /v1/security/totp/generate |
| 認證 | 設置 GATEWAY_AUTH_TOKEN 時需要 Authorization: Bearer <token> |
| 類別 | auth |
響應體
{ "secret": "JBSWY3DPEHPK3PXP", "qrCodeUrl": "otpauth://totp/Minara:[email protected]?secret=JBSWY3DPEHPK3PXP&issuer=Minara", "qrcode": "data:image/png;base64,..." }說明
失敗時返回 { error, status, message },其中 error 是穩定的機器碼。第二因素被拒會映射到一組固定值:invalid_totp、totp_required、invalid_email_code、email_code_required、verification_locked(電子郵件驗證碼錯誤次數過多,message 會給出等待時長)、totp_state_conflict(帳戶已處於請求的狀態)、totp_not_provisioned(尚未產生密鑰)、rate_limited。請求體不合法時返回 400,error 按端點分別為 totp_code_required、totp_and_email_required 或 settings_payload_invalid。網關無法歸類的失敗保留該端點自身的 <action>_failed,並配一條通用文案;上游原文只寫入伺服器日誌。