Skip to content

Bind MFA authentication elements

This document is automatically generated based on https://github.com/authing/authing-docs-factory based on https://api-explorer.genauth.ai V3 API, and is consistent with API parameters and return results. If the description of this document is incorrect, please refer to V3 API.

Bind MFA elements.

Method name

AuthenticationClient.enrollFactor

Request parameters

NameTypeIs it requiredDefault valueDescriptionSample value
enrollmentData<a EnrollFactorEnrollmentDataDtoYes-Verification information required for the corresponding authentication factor when binding the MFA authentication factor.
enrollmentTokenstringYes-The enrollmentToken returned by the "Initiate a request to bind an MFA authentication factor" interface. This token is valid for one minute.TQoCISidM0kBji0dxRi3afSDtkvvMiUphenIgLF87y+JOw4T8fDWOsHHXIcvZ2EVESXhTrfGyh1iGf52Cg9e9byeFQvm1VZ0QWrwmzwpntFAVtf1IP9LqVhmzXhBMFvLOcU/z1Eh/n0CrwX0uHNpJoMW9lp9AqHd9HvauaGKX+Y=
factorTypestringyes-MFA authentication factor type:
- OTP: OTP
- SMS: SMS
- EMAIL: Email
- FACE: Face
SMS

Sample code

ts
import { AuthenticationClient, Models } from "authing-node-sdk";

const authenticationClient = new AuthenticationClient({
  // Need to be replaced with your GenAuth AppId, Secret and Host
  appId: "GEN_AUTH_APP_ID",
  appSecret: "GEN_AUTH_APP_SECRET",
  appHost: "GEN_AUTH_APP_HOST",
});

(async () => {
  // Please call the login interface to get access_token first, and call the setAccessToken method to set access_token
  authenticationClient.setAccessToken("REPLACE_ME_WITH_REAL_ACCESS_TOKEN");

  const result = await authenticationClient.enrollFactor({
    factorType: Models.EnrollFactorDto.factorType.SMS,
    enrollmentToken:
      "TQoCISidM0kBji0dxRi3afSDtkvvMiUphenIgLF87y+JOw4T8fDWOsHHXIcvZ2EVESXhTrfGyh1iGf52Cg9e9byeFQvm1VZ0QWrwmzwpntFAVtf1IP9LqVhmzXhBMFvLOcU/z1Eh/n0CrwX0uHNpJoMW9lp9AqHd9HvauaGKX+Y=",
    enrollmentData: {
      passCode: "123456",
    },
  });

  console.log(JSON.stringify(result, null, 2));
})();

Request response

Type: EnrollFactorRespDto

NameTypeDescription
statusCodenumberBusiness status code, which can be used to determine whether the operation is successful. 200 means success.
messagestringDescription
apiCodenumberSegmented error code, which can be used to get the specific error type (successful requests are not returned). For a detailed list of error codes, see: API Code List
requestIdstringRequest ID. This will be returned when the request fails.

Sample result:

json
{
  "statusCode": 200,
  "message": "Operation successful",
  "requestId": "934108e5-9fbf-4d24-8da1-c330328abd6c"
}

Data structure

EnrollFactorEnrollmentDataDto

NameTypeIs it required?DescriptionSample value
passCodestringNoThis parameter is required when binding SMS, email verification code, or OTP authentication factors. The value is SMS/email/OTP verification code.123456
photostringNoBind FACE This parameter is required when binding an authentication element of type FACE. The value is the link of the bound face image.132434235ad244
isExternalPhotobooleanNoThis parameter is required when binding an authentication element of type FACE. Whether it is an external link image.true

Agent infrastructure for identity, memory, and web action.