Zitadel PHP Client 1.3.6 Help

TOTP

Here you will learn, how to set up a TOTP generator for a user.

First steps

First, we have to initialize the class and set the user id.

use ZitadelPhpClient\User\SetupTwoFactorAuth\TOTP; $totp = new TOTP($settings); $totp->setUserId("12345678");

Start the TOTP setup

$totp->start();

After running the command, you can get the TOTP-Secret, the TOTP-URI and the QR-Code for Authenticator-Apps.

TOTP-Secret

$totp->getSecret();

TOTP-URI

$totp->getURI();

QR-Code

$totp->getQRCode();

This function returns a Base64-encoded SVG image url e.g. data:image/svg+xml;base64,PD94....

Verify and finish the TOTP-Setup

if ($totp->verify("TOTP-Code")) { echo "Setup finished"; } else { echo "Setup failed"; }
Last modified: 27 March 2024