# AuthenticationRequest

Artifact: [androidx.biometric:biometric](https://developer.android.com/jetpack/androidx/releases/biometric) [View Source](https://cs.android.com/search?q=file:androidx/biometric/AuthenticationRequest.kt+class:androidx.biometric.AuthenticationRequest) Added in [1.4.0-beta01](https://developer.android.com/jetpack/androidx/releases/biometric#1.4.0-beta01)

*** ** * ** ***


```
abstract class AuthenticationRequest
```

<br />

Known direct subclasses [AuthenticationRequest.Biometric](https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest.Biometric), [AuthenticationRequest.Credential](https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest.Credential)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest.Biometric` | A set of configurable options for how the `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt` should appear and behave with biometric authentication with fallbacks. |
| `https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest.Credential` | A set of configurable options for how the `https://developer.android.com/reference/kotlin/androidx/biometric/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:

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

to perform a basic credential authentication request do:

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

Backward Compatibility Notes:

1. \< API 30: `https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest.Credential` (device credential only) is not supported.

2. \< API 28: For `https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest.Biometric.Strength.Class3` + `https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest.Biometric.Fallback.DeviceCredential`, `https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest.Biometric.Strength.Class3#cryptoObject()` cannot be used

3. API 28/29: `https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest.Biometric.Strength.Class3` + `https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest.Biometric.Fallback.DeviceCredential` is not supported.

## Summary

| ### Nested types |
|---|
| `class https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest.Biometric : https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest` A set of configurable options for how the `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt` should appear and behave with biometric authentication with fallbacks. |
| `class https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest.Biometric.Builder` Builder used to create an instance of `https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest.Biometric`. |
| `abstract class https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest.Biometric.Fallback` Fallback options for the biometric authentication. |
| `class https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest.Biometric.Fallback.CustomOption : https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest.Biometric.Fallback` 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. |
| `object https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest.Biometric.Fallback.DeviceCredential : https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest.Biometric.Fallback` Device credential as the fallback. |
| `abstract class https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest.Biometric.Strength` Types of biometric strength for the prompt. |
| `object https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest.Biometric.Strength.Class2 : https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest.Biometric.Strength` Class 2 (formerly Weak). |
| `class https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest.Biometric.Strength.Class3 : https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest.Biometric.Strength` Class 3 (formerly Strong). |
| `abstract class https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest.BodyContent` Types of the body content to be displayed on the prompt. |
| `class https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest.BodyContent.ContentViewWithMoreOptionsButton : https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest.BodyContent` A view with "more options" button. |
| `class https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest.BodyContent.PlainText : https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest.BodyContent` Plain text description as body content. |
| `class https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest.BodyContent.VerticalList : https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest.BodyContent` A vertical list as body content. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresApi(value = 30) class https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest.Credential : https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest` A set of configurable options for how the `https://developer.android.com/reference/kotlin/androidx/biometric/BiometricPrompt` should appear and behave with device credential only. |
| `class https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest.Credential.Builder` Builder used to create an instance of `https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest.Credential`. |

| ### Public companion functions |
|---|---|
| `inline https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest.Biometric` | `https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest#biometricRequest(kotlin.String,kotlin.Array,kotlin.Function1)( title: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, vararg authFallbacks: https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest.Biometric.Fallback, init: https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest.Biometric.Builder.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html )` Construct an instance of `https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest.Biometric` that includes a set of configurable options for how the biometric prompt should appear and behave with biometric authentication with fallbacks. |
| `https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest.Credential` | `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresApi(value = 30) https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest#credentialRequest(kotlin.String,kotlin.Function1)(title: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, init: https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest.Credential.Builder.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` Construct an instance of `https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest.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 `https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest.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 `https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest.Biometric.Builder` instead.

| Parameters |
|---|---|
| `title: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | The title of the prompt. |
| `vararg authFallbacks: https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest.Biometric.Fallback` | A list of `https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest.Biometric.Fallback` options (up to `https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest.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: https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest.Biometric.Builder.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | A block to configure the `https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest.Biometric` instance. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if more than one `https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest.Biometric.Fallback.DeviceCredential` is provided, or if the total number of fallbacks exceeds `https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest.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-beta01](https://developer.android.com/jetpack/androidx/releases/biometric#1.4.0-beta01)

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

Construct an instance of `https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest.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 `https://developer.android.com/reference/kotlin/androidx/biometric/AuthenticationRequest.Credential.Builder` instead.