finish_totp_setup
POST
/api/v1/auth/mfa/totp/setup/finish
const url = 'https://example.com/api/v1/auth/mfa/totp/setup/finish';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"code":"example","flow_token":"example","name":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}use serde_json::json;use reqwest;
#[tokio::main]pub async fn main() { let url = "https://example.com/api/v1/auth/mfa/totp/setup/finish";
let payload = json!({ "code": "example", "flow_token": "example", "name": "example" });
let mut headers = reqwest::header::HeaderMap::new(); headers.insert("Authorization", "Bearer <token>".parse().unwrap()); headers.insert("Content-Type", "application/json".parse().unwrap());
let client = reqwest::Client::new(); let response = client.post(url) .headers(headers) .json(&payload) .send() .await;
let results = response.unwrap() .json::<serde_json::Value>() .await .unwrap();
dbg!(results);}curl --request POST \ --url https://example.com/api/v1/auth/mfa/totp/setup/finish \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "code": "example", "flow_token": "example", "name": "example" }'Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”Media typeapplication/json
object
code
required
string
flow_token
required
string
name
string | null
Examplegenerated
{ "code": "example", "flow_token": "example", "name": "example"}Responses
Section titled “Responses”TOTP MFA enabled and recovery codes returned
Media typeapplication/json
统一 API 响应格式
成功: { "code": "success", "msg": "", "data": {...} }
失败: { "code": "auth.credentials_failed", "msg": "Invalid Credentials" }
object
code
required
string
data
object
factor
required
object
enabled_at
required
string
id
required
integer format: int64
last_used_at
string | null
method
required
只返回长期持久化 factor。恢复码和邮箱验证码不会出现在 MFA factor 列表里。
string
name
required
string
recovery_codes
required
Array<string>
error
msg
required
string
Example
{ "code": "success", "data": { "factor": { "method": "totp" } }}Unauthorized