NATSotp.mfa.factor-bind创建 MFA 因素
Try it 面板需要启用 JavaScript。
创建处于待确认状态的 TOTP 因素并生成秘钥;秘钥只存在 otp_service,对调用方仅返回 otpauth URI。
Request Payload
消息格式:JSON
| Name | Data Type | Required | Description |
|---|---|---|---|
| userId | string | Yes | 用户 ID |
| type | string | Yes | 因素类型:totp |
type RequestBody = {
/** 用户 ID */
userId: string
/** 因素类型:totp */
type: string
}{
"userId": "01JD8SEGQ0P9N2XK4L7VDH3T6C",
"type": "totp"
}Response Payload
回复使用统一信封 {id, code, messages, result},其 result:
| Name | Data Type | Required | Description |
|---|---|---|---|
| factorId | string | Yes | 因素 ID |
| type | string | Yes | 因素类型 |
| status | string | Yes | 固定为 pending |
| otpauthUrl | string | Yes | 验证器扫码 / 录入的 otpauth URI |
| expiresAt | string | Yes | 待确认状态过期时间 |
type ResponseBody = {
/** 因素 ID */
factorId: string
/** 因素类型 */
type: string
/** 固定为 pending */
status: string
/** 验证器扫码 / 录入的 otpauth URI */
otpauthUrl: string
/** 待确认状态过期时间 */
expiresAt: string
}{
"factorId": "01JD8SKH5N6P9W5XP9T4WDJ7U0C",
"type": "totp",
"status": "pending",
"otpauthUrl": "otpauth://totp/Xeegam%20Passport:chenlin?secret=JBSWY3DPEHPK3PXP&issuer=Xeegam%20Passport",
"expiresAt": "2026-10-14T08:50:00Z"
}Response Code
回复使用统一信封 {id, code, messages, result},其 code 字段:
| code | Meaning | Notes |
|---|---|---|
| 0 | 成功 | 创建 MFA 因素 |
| 2205 | 因素类型已存在 |
Examples
{ "userId": "01JD8SEGQ0P9N2XK4L7VDH3T6C", "type": "totp" }
{
"id": "01JD8SVFJ1U7W4XT",
"code": 0,
"messages": [],
"result": {
"factorId": "01JD8SKH5N6P9W5XP9T4WDJ7U0C",
"type": "totp",
"status": "pending",
"otpauthUrl": "otpauth://totp/Xeegam%20Passport:chenlin?secret=JBSWY3DPEHPK3PXP&issuer=Xeegam%20Passport",
"expiresAt": "2026-10-14T08:50:00Z"
}
}