# AuthenticationAction

Artifact: [androidx.credentials:credentials](https://developer.android.com/jetpack/androidx/releases/credentials) [View Source](https://cs.android.com/search?q=file:androidx/credentials/provider/AuthenticationAction.kt+class:androidx.credentials.provider.AuthenticationAction) Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/credentials#1.2.0)

*** ** * ** ***

<br />

```
class AuthenticationAction
```

<br />

*** ** * ** ***

An entry on the selector, denoting that the provider service is locked and authentication is needed to proceed.

Providers should set this entry when the provider app is locked, and no credentials can be returned. Providers must set the `https://developer.android.com/reference/android/app/PendingIntent.html` that leads to their unlock activity. When the user selects this entry, the corresponding `https://developer.android.com/reference/android/app/PendingIntent.html` is fired and the unlock activity is invoked.

When the user is done with the authentication flow and the provider has credential entries to return, provider must call `https://developer.android.com/reference/android/app/Activity.html#setResult(int)` with the result code as `https://developer.android.com/reference/android/app/Activity.html#RESULT_OK`, and the `https://developer.android.com/reference/android/content/Intent.html` data that has been prepared by setting `https://developer.android.com/reference/kotlin/androidx/credentials/provider/BeginGetCredentialResponse` using `https://developer.android.com/reference/kotlin/androidx/credentials/provider/PendingIntentHandler#setBeginGetCredentialResponse(android.content.Intent,androidx.credentials.provider.BeginGetCredentialResponse)`, or by setting `https://developer.android.com/reference/kotlin/androidx/credentials/exceptions/GetCredentialException` using `https://developer.android.com/reference/kotlin/androidx/credentials/provider/PendingIntentHandler#setGetCredentialException(android.content.Intent,androidx.credentials.exceptions.GetCredentialException)` before ending the activity. If the provider does not have a credential, or an exception to return, provider must call `https://developer.android.com/reference/android/app/Activity.html#setResult(int)` with the result code as `https://developer.android.com/reference/android/app/Activity.html#RESULT_CANCELED`. Setting the result code to `https://developer.android.com/reference/android/app/Activity.html#RESULT_CANCELED` will re-surface the selector, with this authentication action labeled as having no valid credentials.

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-null-pointer-exception/index.html` | If the `https://developer.android.com/reference/kotlin/androidx/credentials/provider/AuthenticationAction#pendingIntent()` or `https://developer.android.com/reference/kotlin/androidx/credentials/provider/AuthenticationAction#title()` is null |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | If the `https://developer.android.com/reference/kotlin/androidx/credentials/provider/AuthenticationAction#title()` is empty |

| See also |
|---|---|
| `https://developer.android.com/reference/android/service/credentials/BeginGetCredentialResponse.html` | for more usage details. |

## Summary

| ### Nested types |
|---|
| `class https://developer.android.com/reference/kotlin/androidx/credentials/provider/AuthenticationAction.Builder` A builder for `https://developer.android.com/reference/kotlin/androidx/credentials/provider/AuthenticationAction` |

| ### Public companion functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/credentials/provider/AuthenticationAction?` | `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresApi(value = 34) https://developer.android.com/reference/kotlin/androidx/credentials/provider/AuthenticationAction#fromAction(android.service.credentials.Action)(authenticationAction: https://developer.android.com/reference/android/service/credentials/Action.html)` Converts a framework `https://developer.android.com/reference/android/service/credentials/Action.html` class to a Jetpack `https://developer.android.com/reference/kotlin/androidx/credentials/provider/AuthenticationAction` class |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/credentials/provider/AuthenticationAction#AuthenticationAction(kotlin.CharSequence,android.app.PendingIntent)(title: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html, pendingIntent: https://developer.android.com/reference/android/app/PendingIntent.html)` constructs an instance of `https://developer.android.com/reference/kotlin/androidx/credentials/provider/AuthenticationAction` |

| ### Public functions |
|---|---|
| `open operator https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/credentials/provider/AuthenticationAction#equals(kotlin.Any)(other: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)` |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/credentials/provider/AuthenticationAction#hashCode()()` |

| ### Public properties |
|---|---|
| `https://developer.android.com/reference/android/app/PendingIntent.html` | `https://developer.android.com/reference/kotlin/androidx/credentials/provider/AuthenticationAction#pendingIntent()` the `https://developer.android.com/reference/android/app/PendingIntent.html` that will get invoked when the user selects this entry, must be created with a unique request code per entry, with flag `https://developer.android.com/reference/android/app/PendingIntent.html#FLAG_MUTABLE` to allow the Android system to attach the final request, and NOT with flag `https://developer.android.com/reference/android/app/PendingIntent.html#FLAG_ONE_SHOT` as it can be invoked multiple times |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html` | `https://developer.android.com/reference/kotlin/androidx/credentials/provider/AuthenticationAction#title()` the title to be shown with this entry on the account selector UI |

## Public companion functions

### fromAction

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/credentials#1.3.0)

```
@RequiresApi(value = 34)
fun fromAction(authenticationAction: Action): AuthenticationAction?
```

Converts a framework `https://developer.android.com/reference/android/service/credentials/Action.html` class to a Jetpack `https://developer.android.com/reference/kotlin/androidx/credentials/provider/AuthenticationAction` class

Note that this API is not needed in a general credential retrieval flow that is implemented using this jetpack library, where you are only required to construct an instance of `https://developer.android.com/reference/kotlin/androidx/credentials/provider/AuthenticationAction` to populate the `https://developer.android.com/reference/kotlin/androidx/credentials/provider/BeginGetCredentialResponse`, along with setting other entries.

| Parameters |
|---|---|
| `authenticationAction: https://developer.android.com/reference/android/service/credentials/Action.html` | the instance of framework action class to be converted |

## Public constructors

### AuthenticationAction

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/credentials#1.2.0)

```
AuthenticationAction(title: CharSequence, pendingIntent: PendingIntent)
```

constructs an instance of `https://developer.android.com/reference/kotlin/androidx/credentials/provider/AuthenticationAction`

| Parameters |
|---|---|
| `title: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html` | the title to be shown with this entry on the account selector UI |
| `pendingIntent: https://developer.android.com/reference/android/app/PendingIntent.html` | the `https://developer.android.com/reference/android/app/PendingIntent.html` that will get invoked when the user selects this entry, must be created with a unique request code per entry, with flag `https://developer.android.com/reference/android/app/PendingIntent.html#FLAG_MUTABLE` to allow the Android system to attach the final request, and NOT with flag `https://developer.android.com/reference/android/app/PendingIntent.html#FLAG_ONE_SHOT` as it can be invoked multiple times |

## Public functions

### equals

```
open operator fun equals(other: Any?): Boolean
```

### hashCode

```
open fun hashCode(): Int
```

## Public properties

### pendingIntent

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/credentials#1.2.0)

```
val pendingIntent: PendingIntent
```

the `https://developer.android.com/reference/android/app/PendingIntent.html` that will get invoked when the user selects this entry, must be created with a unique request code per entry, with flag `https://developer.android.com/reference/android/app/PendingIntent.html#FLAG_MUTABLE` to allow the Android system to attach the final request, and NOT with flag `https://developer.android.com/reference/android/app/PendingIntent.html#FLAG_ONE_SHOT` as it can be invoked multiple times

### title

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/credentials#1.2.0)

```
val title: CharSequence
```

the title to be shown with this entry on the account selector UI