AuthenticationRequest


abstract class AuthenticationRequest

Known direct subclasses
AuthenticationRequest.Biometric

A set of configurable options for how the BiometricPrompt should appear and behave with biometric authentication with fallbacks.

AuthenticationRequest.Credential

A set of configurable options for how the BiometricPrompt should appear and behave with device credential only.


Types for configuring authentication prompt with options that are commonly used together. For example, to perform a basic biometric authentication request do:

val request = biometricRequest(
title = "title",
Biometric.Fallback.CustomOption("cancel")
)
{
setSubtitle("sub title")
setMinStrength(Biometric.Strength.Class2)
}

to perform a basic credential authentication request do:

val request = credentialRequest(
title = "title",
)
{
setSubtitle("sub title")
}

Backward Compatibility Notes:

  1. < API 30: Credential (device credential only) is not supported.

  2. < API 28: For Biometric.Strength.Class3 + Biometric.Fallback.DeviceCredential, Biometric.Strength.Class3.cryptoObject cannot be used

  3. API 28/29: Biometric.Strength.Class3 + Biometric.Fallback.DeviceCredential is not supported.

Summary

Nested types

A set of configurable options for how the BiometricPrompt should appear and behave with biometric authentication with fallbacks.

Builder used to create an instance of Biometric.

Fallback options for the biometric authentication.

Custom Fallback option displayed as the negative button in prompt authentication screen if it is the only option or displayed in a list in the fallback options page if there are more than one.

Device credential as the fallback.

Types of biometric strength for the prompt.

Class 2 (formerly Weak).

Class 3 (formerly Strong).

Types of the body content to be displayed on the prompt.

A view with "more options" button.

Plain text description as body content.

A vertical list as body content.

A set of configurable options for how the BiometricPrompt should appear and behave with device credential only.

Builder used to create an instance of Credential.

Public companion functions

inline AuthenticationRequest.Biometric
biometricRequest(
    title: String,
    vararg authFallbacks: AuthenticationRequest.Biometric.Fallback,
    init: AuthenticationRequest.Biometric.Builder.() -> Unit
)

Construct an instance of Biometric that includes a set of configurable options for how the biometric prompt should appear and behave with biometric authentication with fallbacks.

AuthenticationRequest.Credential

Construct an instance of Credential that includes a set of configurable options for how the prompt should appear and behave with device credential authentication.

Public companion functions

biometricRequest

inline fun biometricRequest(
    title: String,
    vararg authFallbacks: AuthenticationRequest.Biometric.Fallback,
    init: AuthenticationRequest.Biometric.Builder.() -> Unit
): AuthenticationRequest.Biometric

Construct an instance of Biometric that includes a set of configurable options for how the biometric prompt should appear and behave with biometric authentication with fallbacks.

Note for Java users: This method is intended for use in Kotlin. For Java, please use Biometric.Builder instead.

Parameters
title: String

The title of the prompt.

vararg authFallbacks: AuthenticationRequest.Biometric.Fallback

A list of Biometric.Fallback options (up to Biometric.getMaxFallbackOptions). If empty, a default "Cancel" button is used; If one option is provided, it is displayed as the negative button on the primary authentication screen. If multiple options are provided, these are displayed as a list on a separate fallback options page.

init: AuthenticationRequest.Biometric.Builder.() -> Unit

A block to configure the Biometric instance.

Throws
IllegalArgumentException

if more than one Biometric.Fallback.DeviceCredential is provided, or if the total number of fallbacks exceeds Biometric.getMaxFallbackOptions.

Compatibility Note: Prior to Build.VERSION_CODES_FULL.BAKLAVA_1 (API 36.1), only one fallback option is supported. If multiple options are provided on earlier Android versions, only the first fallback will be displayed as the negative button (without an icon), and the remaining fallbacks will be ignored.

credentialRequest

Added in 1.4.0-alpha06
@RequiresApi(value = 30)
fun credentialRequest(title: String, init: AuthenticationRequest.Credential.Builder.() -> Unit): AuthenticationRequest.Credential

Construct an instance of Credential that includes a set of configurable options for how the prompt should appear and behave with device credential authentication.

Note for Java users: This method is intended for use in Kotlin. For Java, please use Credential.Builder instead.