Child pages
  • UAPI Functions - TwoFactorAuth::set_user_configuration

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

 

Description

Excerpt
This function configures the two-factor authentication settings for an account.

Panel
bgColor#F2F2F2
borderStylenone

Examples 


Panel
bgColor#FFFFFF
borderStylenone
Expand
titlecPanel or Webmail Session URL
Code Block
languagetext
https://hostname.example.com:2083/cpsess##########/execute/TwoFactorAuth/set_user_configuration?secret=JBSWY3DPEHPK3PXP&tfa_token=528112

Include Page
LIB:_CallUAPIFromBrowserLink
LIB:_CallUAPIFromBrowserLink

Expand
titleLiveAPI PHP Class
Code Block
languagephp
linenumberstrue
$cpanel = new CPANEL(); // Connect to cPanel - only do this once.

// Set TwoFactorAuth user configuration.
$sa_settings = $cpanel->uapi(
    'TwoFactorAuth', 'set_user_configuration',
    array(
        'secret'     => 'JBSWY3DPEHPK3PXP',
        'tfa_token   => '528112',
    )
);

Include Page
LIB:_LiveAPIPHPLink
LIB:_LiveAPIPHPLink

 

Expand
titleLiveAPI Perl Module
Code Block
languageperl
linenumberstrue
my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.

# Set TwoFactorAuth user configuration.
my $sa_settings = $cpliveapi->uapi(
    'TwoFactorAuth', 'set_user_configuration',
    {
        'secret'     => 'JBSWY3DPEHPK3PXP',
        'tfa_token   => '528112',
    }
);

Include Page
LIB:_LiveAPIPerlLink
LIB:_LiveAPIPerlLink

 

Expand
titlecPanel Template Toolkit
Code Block
languagexml
<!-- Set TwoFactorAuth user configuration. -->
[% SET sa_settings = execute('TwoFactorAuth', 'set_user_configuration' 
   { 
      secret => 'JBSWY3DPEHPK3PXP', 
      tfa_token => '528112' 
   } 
); %]

Include Page
LIB:_TTLink
LIB:_TTLink

Expand
titleCommand Line
Code Block
uapi --user=username TwoFactorAuth set_user_configuration secret=JBSWY3DPEHPK3PXP tfa_token=528112

Include Page
LIB:_UAPICLINote
LIB:_UAPICLINote

Expand
titleOutput (JSON)
Code Block
languagetext
linenumberstrue
{
    "messages": null,
    "errors": null,
    "status": 1,
    "metadata": {},
    "data": {
        "tfa_configured": 1
    }
}

Include Page
LIB:_cPanelAPIShellNote
LIB:_cPanelAPIShellNote

   

Parameters

ParameterTypeDescriptionPossible valuesExample
secretstring

Required

The 16-character string that UAPI's TwoFactorAuth::generate_user_configuration function generates.

A valid 16-character string.
JBSWY3DPEHPK3PXP
tfa_tokeninteger

Required

The six-digit security code that the time-based one-time password (TOTP) authentication app generates.

A six-digit integer.
528112

Returns

ReturnTypeDescriptionPossible valuesExample
tfa_configuredBooleanWhether two-factor authentication is enabled.
  • 1 — Enabled.
  • 0 — Disabled.

1