Xbasic

a5wcb_googleAuthenticatorQRCode Function

Syntax

C a5wcb_googleAuthenticatorQRCode(C issuer ,C userid ,C secret [,N width[,N height[,L returnB64image]])

Arguments

issuerCharacter

An arbitrary string that identifies your application (no spaces). For example, "MyWebApp".

useridCharacter

An arbitrary string to identify the user.

secretCharacter

The secret used to generate tokens. The secret must be 16 characters long with no spaces.

widthNumeric

Default = 400. Width of the QR Code in pixels.

heightNumeric

Default = 400. Height of the QR Code in pixels.

returnB64imageLogical

Default = .f.. If .t. the base64 encoded image for the QR Code bitmap is returned. If .f. the QR code is displayed in a pop-up window (Desktop Applications Only).

Returns

resultCharacter

Returns the base64 encoded QR Code if returnB64image has been set to .t.. Otherwise, returns nothing.

Description

Displays a QR code to register a new application in the Google Authenticator mobile application.

Discussion

The Google Authenticator App is used to display a time based token. In order to register a new application in the Google Authenticator app, a QR code is scanned. The a5wcb_googleAuthenticatorQRCode() function can be used to generate this QR Code.

Example

dim issuer as c = "MyWebApp"
dim userid as c = "[email protected]"
dim secret as c = "abcdefghijklmnop"
b64 = a5wcb_googleAuthenticatorQRCode(issuer,userid,secret,300,300,.t.)

showvar(b64)