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

 

Description

This function generates a random secret and a one-time password authentication (OTP auth) URL for the user. Use the secret that this function returns and a valid verification token with WHM API 1's twofactorauth_set_tfa_config function to configure Two-Factor Authentication (2FA) on an account.

 

Examples 


 JSON API
https://hostname.example.com:2087/cpsess##########/json-api/twofactorauth_generate_tfa_config?api.version=1
 XML API
https://hostname.example.com:2087/cpsess##########/xml-api/twofactorauth_generate_tfa_config?api.version=1
 Command Line
whmapi1 twofactorauth_generate_tfa_config


Notes:

  • 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)
{  
   "data":{  
      "otpauth_str":"otpauth://totp/Example:root?secret=CAOXW75HKYJJ6E5Y&issuer=Example",
      "secret":"CAOXW75HKYJJ6E5Y"
   },
   "metadata":{  
      "version":1,
      "reason":"OK",
      "result":"1",
      "command":"twofactorauth_generate_tfa_config"
   }
}
 Output (XML)
<result>
    <data>
        <otpauth_str>
         otpauth://totp/Example:root?secret=WJ73QJSKZBXCFIPZ&issuer=Example
        </otpauth_str>
        <secret>WJ73QJSKZBXCFIPZ</secret>
    </data>
    <metadata>
        <version>1</version>
        <reason>OK</reason>
        <result>1</result>
        <command>/twofactorauth_generate_tfa_config</command>
    </metadata>
</result>


Note:

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

Parameters

This function does not accept parameters.

Returns

Return

TypeDescriptionPossible valuesExample

otpauth_str

string

A one-time authentication URL to encode as the QR code.

 

A valid OTP auth URL.

 Click to view...
otpauth://totp/Example:root?secret=CAOXW75HKYJJ6E5Y&issuer=Example

secret

string

A generated code for use with 2FA.

 

A valid security code.

WJ73QJSKZBXCFIPZ