Child pages
  • WHM API 1 Functions - twofactorauth_set_tfa_config
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

 

Description

This function sets the secret and the authentication code for Two-Factor Authentication (2FA) for the root or reseller account. You can generate a random secret and an OTP authentication URL with WHM API 1's twofactorauth_generate_tfa_config function.

Examples 


 JSON API
https://hostname.example.com:2087/cpsess##########/json-api/twofactorauth_set_tfa_config?api.version=1&secret=WJ73QJSKZBXCFIPZ&tfa_token=227174
 XML API
https://hostname.example.com:2087/cpsess##########/xml-api/twofactorauth_set_tfa_config?api.version=1&secret=WJ73QJSKZBXCFIPZ&tfa_token=227174
 Command Line
whmapi1 twofactorauth_set_tfa_config secret=WJ73QJSKZBXCFIPZ tfa_token=227174


Notes:

  • Unless otherwise noted, you must URI-encode values.
  • For more information and additional output options, read our Guide to WHM API 1 documentation or run the whmapi1 --help command.
  • If you run CloudLinux™, you must use the full path of the whmapi1 command:

    /usr/local/cpanel/bin/whmapi1

 Output (JSON)
{
   "metadata" : {
      "version":1,
      "reason":"OK",
      "command":"twofactorauth_set_tfa_config",
      "result":"1"
   },
   "data":{
      "success":1
   }
}
 Output (XML)
<result>
    <metadata>
        <version>1</version>
        <reason>OK</reason>
        <result>1</result>
        <command>twofactorauth_set_tfa_config</command>
    </metadata>
    <data>
        <success>1</success>
    </data>
</result>


Note:

Use WHM's API Shell interface (WHM >> Home >> Development >> API Shell) to directly test WHM API calls.

Parameters

ParameterTypeDescriptionPossible valuesExample
secretstring

Required

A generated code for use with 2FA.

A valid 16-character Base32 string.
WJ73QJSKZBXCFIPZ
tfa_tokenstring

Required

The time-based one-time password (TOTP) that the authentication app provides.

A valid security code.
227174

Returns

ReturnTypeDescriptionPossible valuesExample
successBoolean

Whether the account successfully enabled 2FA.

  • 1 — Enabled.
  • 0 — Not enabled.
1
  • No labels