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 


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

{  
   "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"
   }
}
<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>

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.

otpauth://totp/Example:root?secret=CAOXW75HKYJJ6E5Y&issuer=Example

secret

string

A generated code for use with 2FA.

 

A valid security code.

WJ73QJSKZBXCFIPZ