Authing DocsDocuments
Concept
Guides
Development Integration
Application integration
Concept
Guides
Development Integration
Application integration
Old Version
Development Integration
  • Single Sign-On (SSO)
  • Login component

  • JavaScript/Node.js

    • User Authentication Module

      • User authentication module
      • Standard agreement certification module
      • Scan code login module
      • Multi-factor authentication module
      • Social login module
      • Corporate identity source login module
      • Main authentication module
    • Management Module

  • Java / Kotlin

  • Python

  • C#

  • PHP

  • Go

  • Ruby
  • Android

  • iOS

  • Flutter

  • React Native
  • WeChat Mini Program
  • WeChat webpage authorization
  • Framework Integration
  • Error code
  1. Development Integration
  2. /
  3. JavaScript/Node.js
  4. /
  5. User Authentication Module
  6. /
  7. Multi-factor authentication module

¶ MfaAuthenticationClient

Update Time: 2022-10-10 11:16:11
Edit

This client is used to bind the MFA authenticator, unbind the MFA authenticator, and second authentication of the user.

Request to bind MFA authenticator:

import { AuthenticationClient } from 'authing-js-sdk'
const authenticationClient = new AuthenticationClient({
  appId: 'AUTHING_APP_ID',
  appHost: 'https://xxx.authing.cn',
})
await authenticationClient.mfa.assosicateMfaAuthenticator({
  authenticatorType: 'totp',
})

Verify the MFA secondary password:

import { AuthenticationClient } from 'authing-js-sdk'
const authenticationClient = new AuthenticationClient({
  appId: 'AUTHING_APP_ID',
  appHost: 'https://xxx.authing.cn',
})
await authenticationClient.mfa.verifyTotpMfa({
  totp: '112233',
  mfaToken: 'xxx',
})

¶ Get MFA authenticator

MfaAuthenticationClient().getMfaAuthenticators()

Get MFA authenticator

¶ Parameter

¶ Example

const authenticationClient = new AuthenticationClient({
  appId: 'AUTHING_APP_ID',
  appHost: 'https://xxx.authing.cn',
})
const authenticators = await authenticationClient.mfa.getMfaAuthenticators({
  type: 'totp',
})

¶ Return value

  • Promise<IMfaAuthenticators>

¶ Request the QR code and credential information of MFA authenticator

MfaAuthenticationClient().assosicateMfaAuthenticator()

Request the QR code and credential information of MFA authenticator

¶ Parameter

¶ Example

const authenticationClient = new AuthenticationClient({
  appId: 'AUTHING_APP_ID',
  appHost: 'https://xxx.authing.cn',
})
const authenticators = await authenticationClient.mfa.assosicateMfaAuthenticator(
  { authenticatorType: 'totp' }
)

¶ Return value

  • Promise<IMfaAssociation>

¶ Unbind MFA authenticator

MfaAuthenticationClient().deleteMfaAuthenticator()

Unbind MFA authenticator

¶ Parameter

¶ Example

const authenticationClient = new AuthenticationClient({
  appId: 'AUTHING_APP_ID',
  appHost: 'https://xxx.authing.cn',
})
const authenticators = await authenticationClient.mfa.deleteMfaAuthenticator()

¶ Return value

  • Promise<IMfaDeleteAssociation>

¶ Confirm authenticator binding

MfaAuthenticationClient().confirmAssosicateMfaAuthenticator()

Confirm authenticator binding

¶ Parameter

¶ Example

const authenticationClient = new AuthenticationClient({
  appId: 'AUTHING_APP_ID',
  appHost: 'https://xxx.authing.cn',
})
const authenticators = await authenticationClient.mfa.confirmAssosicateMfaAuthenticator(
  { authenticatorType: 'totp', totp: '112233' }
)

¶ Return value

  • Promise<IMfaConfirmAssociation>

¶ Verify MFA one-time-password

MfaAuthenticationClient().verifyTotpMfa()

Verify MFA one-time-password

¶ Parameter

¶ Example

const authenticationClient = new AuthenticationClient({
  appId: 'AUTHING_APP_ID',
  appHost: 'https://xxx.authing.cn',
})
const authenticators = await authenticationClient.mfa.verifyTotpMfa({
  authenticatorType: 'totp',
  totp: '112233',
})

¶ Return value

  • Promise<User>

¶ Verify the SMS one-time-password

MfaAuthenticationClient().verifyAppSmsMfa()

Verify the SMS one-time-password

¶ Parameter

  • options <Object>
  • options.phone <string> user phone number
  • options.code <string> SMS code
  • options.mfaToken <string> mfaToken returned from login interface.

¶ Example

const authenticationClient = new AuthenticationClient({
  appId: 'AUTHING_APP_ID',
  appHost: 'https://xxx.authing.cn',
})
const authenticators = await authenticationClient.mfa.verifySmsMfa({
  mfaToken: 'xxxxxx',
  phone: '188xxxx8888',
  code: 'xxxx',
})

¶ Return value

  • Promise<User>

¶ Verify the email one-time-password

MfaAuthenticationClient().verifyAppEmailMfa()

Verify the email one-time-password.

¶ Parameter

  • options <Object>
  • options.email <string> user email
  • options.code <string> OTP code
  • options.mfaToken <string> mfaToken returned from login interface

¶ Example

const authenticationClient = new AuthenticationClient({
  appId: 'AUTHING_APP_ID',
  appHost: 'https://xxx.authing.cn',
})
const authenticators = await authenticationClient.mfa.verifyAppEmailMfa({
  mfaToken: 'xxxxxx',
  email: 'example@authing.cn',
  code: 'xxxx',
})

¶ Return value

  • Promise<User>

¶ Check the phone number or email binding status

MfaAuthenticationClient().phoneOrEmailBindable()

When the mobile phone or email MFA login is required, and the user has not bound the mobile phone or email address, the user can first enter the mobile phone number or email address. Use this interface to first check whether the mobile phone or email address can be bound, and then perform MFA verification.

¶ Parameter

  • options <Object>
  • [options.email] <string> email to be checked
  • [options.phone] <string> phone number to be checked
  • options.mfaToken <string> mfaToken returned from login interface.

¶ Example

const authenticationClient = new AuthenticationClient({
  appId: 'AUTHING_APP_ID',
  appHost: 'https://xxx.authing.cn',
})
const authenticators = await authenticationClient.mfa.phoneOrEmailBindable({
  mfaToken: 'xxxxxx',
  email: 'example@authing.cn',
})

¶ Return value

  • Promise<boolean>

¶ Check MFA recovery code

MfaAuthenticationClient().verifyTotpRecoveryCode()

Check MFA recovery code.

¶ Parameter

¶ Example

const authenticationClient = new AuthenticationClient({
  appId: 'AUTHING_APP_ID',
  appHost: 'https://xxx.authing.cn',
})
const authenticators = await authenticationClient.mfa.verifyTotpRecoveryCode({
  authenticatorType: 'totp',
  totp: '112233',
})

¶ Return value

  • Promise<User>
Prev: Scan code login module Next: Social login module
  • Get MFA authenticator
  • Request the QR code and credential information of MFA authenticator
  • Unbind MFA authenticator
  • Confirm authenticator binding
  • Verify MFA one-time-password
  • Verify the SMS one-time-password
  • Verify the email one-time-password
  • Check the phone number or email binding status
  • Check MFA recovery code

User identity management

Integrated third-party login
Mobile phone number flash check (opens new window)
Universal login form component
Custom authentication process

Enterprise internal management

Single Sign On
Multi-factor Authentication
Authority Management

Developers

Development Document
Framework Integration
Blog (opens new window)
GitHub (opens new window)
Community User Center (opens new window)

Company

400 888 2106
sales@authing.cn
16 / F, Block B, NORTH STAR CENTURY CENTER, Beijing(Total)
room 406, 4th floor, zone B, building 1, No. 200, Tianfu Fifth Street, Chengdu(branch)

Beijing ICP No.19051205-1

© Beijing Steamory Technology Co.