TotpSecret

interface TotpSecret


Represents a TOTP secret that is used for enrolling a TOTP second factor. Contains the shared secret key and other parameters to generate time-based one-time passwords. Implements methods to retrieve the shared secret key, generate a QR code URL, and open the QR code URL in an OTP authenticator app.

Summary

Public functions

String

Returns a QR code URL.

String
generateQrCodeUrl(accountName: String, issuer: String)

Returns a QR code URL.

Int

Returns the interval (in seconds) when the OTP codes should change.

Int

Returns the length of the OTP codes to be generated.

Long

Returns the timestamp (in seconds since epoch) by which enrollment should complete.

String

Returns the hashing algorithm used to generate time-based one-time passwords.

String

Returns the enrollment session.

String

Returns the shared secret key/seed used to generate time-based one-time passwords.

Unit
openInOtpApp(qrCodeUrl: String)

Opens the specified QR Code URL in an OTP authenticator app on the device as a new Activity.

Unit
openInOtpApp(qrCodeUrl: String, fallbackUrl: String, activity: Activity)

Opens the specified QR Code URL in an OTP app on the device.

Public functions

generateQrCodeUrl

fun generateQrCodeUrl(): String

Returns a QR code URL. For more details, see Key-Uri-Format. You can display this URL to the end-user as a QR code to be scanned into an OTP authenticator app, like Google Authenticator. Alternatively, you can automatically load this URL into a TOTP authenticator app using openInOtpApp.

Returns
String

A QR code URL String.

generateQrCodeUrl

fun generateQrCodeUrl(accountName: String, issuer: String): String

Returns a QR code URL. For more details, see Key-Uri-Format. You can display this URL to the end-user as a QR code to be scanned into an OTP authenticator app, like Google Authenticator. Alternatively, you can automatically load this URL into a TOTP authenticator app using openInOtpApp.

Parameters
accountName: String

the name of the account/app along with a user identifier..

issuer: String

issuer of the TOTP (the app name).

Returns
String

A QR code URL String.

getCodeIntervalSeconds

fun getCodeIntervalSeconds(): Int

Returns the interval (in seconds) when the OTP codes should change.

Returns
Int

The interval (in seconds) when the OTP codes should change.

getCodeLength

fun getCodeLength(): Int

Returns the length of the OTP codes to be generated.

Returns
Int

Length of the one-time passwords to be generated.

getEnrollmentCompletionDeadline

fun getEnrollmentCompletionDeadline(): Long

Returns the timestamp (in seconds since epoch) by which enrollment should complete.

Returns
Long

The timestamp (in seconds since epoch) by which enrollment should complete.

getHashAlgorithm

fun getHashAlgorithm(): String

Returns the hashing algorithm used to generate time-based one-time passwords.

Returns
String

Hashing algorithm used.

getSessionInfo

fun getSessionInfo(): String

Returns the enrollment session.

getSharedSecretKey

fun getSharedSecretKey(): String

Returns the shared secret key/seed used to generate time-based one-time passwords.

Returns
String

Shared secret key for enrolling in TOTP MFA.

openInOtpApp

fun openInOtpApp(qrCodeUrl: String): Unit

Opens the specified QR Code URL in an OTP authenticator app on the device as a new Activity. The shared secret key and account name will be populated in the OTP authenticator app. The URL uses the otpauth:// scheme and will be opened on an app that handles this scheme, if it exists on the device.

If a suitable OTP authenticator app was not found, this opens the Google Play Store instead, using the following URL: https://play.google.com/store/search?q=otpauth&c=apps.

Parameters
qrCodeUrl: String

the QR Code URL to open.

openInOtpApp

fun openInOtpApp(qrCodeUrl: String, fallbackUrl: String, activity: Activity): Unit

Opens the specified QR Code URL in an OTP app on the device. The shared secret key and account name will be populated in the OTP app. The URL uses the otpauth:// scheme and will be opened on an app that handles this scheme, if it exists on the device.

Parameters
qrCodeUrl: String

the QR Code URL to open.

fallbackUrl: String

the URL to open if a suitable OTP authenticator app was not found.

activity: Activity

a reference to the current activity, to open the OTP authenticator app on.