# GetCredentialRequest.Builder

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

*** ** * ** ***


```
public final class GetCredentialRequest.Builder
```

<br />

*** ** * ** ***

A builder for `https://developer.android.com/reference/androidx/credentials/GetCredentialRequest`.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/credentials/GetCredentialRequest.Builder#Builder()()` |

| ### Public methods |
|---|---|
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/GetCredentialRequest.Builder` | `https://developer.android.com/reference/androidx/credentials/GetCredentialRequest.Builder#addCredentialOption(androidx.credentials.CredentialOption)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/CredentialOption credentialOption)` Adds a specific type of `https://developer.android.com/reference/androidx/credentials/CredentialOption`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/GetCredentialRequest` | `https://developer.android.com/reference/androidx/credentials/GetCredentialRequest.Builder#build()()` Builds a `https://developer.android.com/reference/androidx/credentials/GetCredentialRequest`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/GetCredentialRequest.Builder` | `https://developer.android.com/reference/androidx/credentials/GetCredentialRequest.Builder#setCredentialOptions(kotlin.collections.List)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/CredentialOption> credentialOptions )` Sets the list of `https://developer.android.com/reference/androidx/credentials/CredentialOption`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/GetCredentialRequest.Builder` | `https://developer.android.com/reference/androidx/credentials/GetCredentialRequest.Builder#setOrigin(kotlin.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html origin)` Sets the `https://developer.android.com/reference/androidx/credentials/GetCredentialRequest.Builder#setOrigin(kotlin.String)` of a different application if the request is being made on behalf of that application. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/GetCredentialRequest.Builder` | `https://developer.android.com/reference/androidx/credentials/GetCredentialRequest.Builder#setPreferIdentityDocUi(kotlin.Boolean)(boolean preferIdentityDocUi)` Sets the `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` preferIdentityDocUi to true if the requester wants to prefer using a UI suited for Identity Documents like mDocs, Driving License etc. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/GetCredentialRequest.Builder` | `https://developer.android.com/reference/androidx/credentials/GetCredentialRequest.Builder#setPreferImmediatelyAvailableCredentials(kotlin.Boolean)( boolean preferImmediatelyAvailableCredentials )` Sets whether you prefer the operation to return immediately when there is no available credentials instead of falling back to discovering remote options. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/GetCredentialRequest.Builder` | `https://developer.android.com/reference/androidx/credentials/GetCredentialRequest.Builder#setPreferUiBrandingComponentName(android.content.ComponentName)(https://developer.android.com/reference/android/content/ComponentName.html component)` Sets service `https://developer.android.com/reference/android/content/ComponentName.html` from which the Credential Selector UI will pull its label and icon to render top level branding. |

## Public constructors

### Builder

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

```
public Builder()
```

## Public methods

### addCredentialOption

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

```
public final @NonNull GetCredentialRequest.Builder addCredentialOption(@NonNull CredentialOption credentialOption)
```

Adds a specific type of `https://developer.android.com/reference/androidx/credentials/CredentialOption`.

### build

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

```
public final @NonNull GetCredentialRequest build()
```

Builds a `https://developer.android.com/reference/androidx/credentials/GetCredentialRequest`.

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | If `https://developer.android.com/reference/androidx/credentials/GetCredentialRequest.Builder#credentialOptions()` is empty |

### setCredentialOptions

```
public final @NonNull GetCredentialRequest.Builder setCredentialOptions(
    @NonNull List<@NonNull CredentialOption> credentialOptions
)
```

Sets the list of `https://developer.android.com/reference/androidx/credentials/CredentialOption`.

### setOrigin

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

```
public final @NonNull GetCredentialRequest.Builder setOrigin(@NonNull String origin)
```

Sets the `https://developer.android.com/reference/androidx/credentials/GetCredentialRequest.Builder#setOrigin(kotlin.String)` of a different application if the request is being made on behalf of that application. For API level \>=34, setting a non-null value for this parameter, will throw a SecurityException if android.permission.CREDENTIAL_MANAGER_SET_ORIGIN is not present.

### setPreferIdentityDocUi

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

```
public final @NonNull GetCredentialRequest.Builder setPreferIdentityDocUi(boolean preferIdentityDocUi)
```

Sets the `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` preferIdentityDocUi to true if the requester wants to prefer using a UI suited for Identity Documents like mDocs, Driving License etc.

### setPreferImmediatelyAvailableCredentials

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

```
public final @NonNull GetCredentialRequest.Builder setPreferImmediatelyAvailableCredentials(
    boolean preferImmediatelyAvailableCredentials
)
```

Sets whether you prefer the operation to return immediately when there is no available credentials instead of falling back to discovering remote options. The default value is false.

### setPreferUiBrandingComponentName

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

```
public final @NonNull GetCredentialRequest.Builder setPreferUiBrandingComponentName(ComponentName component)
```

Sets service `https://developer.android.com/reference/android/content/ComponentName.html` from which the Credential Selector UI will pull its label and icon to render top level branding. Your app must have the permission android.permission.CREDENTIAL_MANAGER_SET_ALLOWED_PROVIDERS to specify this, or it would not take effect. Notice that this bit may not take effect for Android API level 33 and below, depending on the pre-34 provider(s) you have chosen.