GetTOTPUrl (open)

Create a url which encodes the TOTP secret for use in external applications

Syntax

LOADLIB "wh::util/otp.whlib";

STRING FUNCTION GetTOTPUrl(STRING secret, STRING account, STRING issuer, RECORD options)

Parameters

STRING secret

The key to use (raw byte value)

STRING account

The name of the user's account (may be left empty)

STRING issuer

The name of the issuer of the secret (may be left empty)

RECORD options

Options

INTEGER digits

The length of the resulting password, range [6-8], defaults to 6

STRING hmac

The HMAC algorithm to use, defaults to "HMAC:SHA-1"

INTEGER interval

The interval to use in seconds, defaults to 30

Return value

STRING

The url that can be used in external applications (for example by encoding it in a scannable QR code)

Description

This function creates a URL that can be used by external applications to initialize TOTP authentication. This URL can be used to create a QR code that can be scanned by such applications. Please note that the 'now' and 'start' options that are supported by GetTOTPCode cannot be specified on a url and that external applications may not support all of the options and will fallback to the defaults.