# BeginGetCredentialResponse.Builder

# BeginGetCredentialResponse.Builder

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

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/credentials/provider/BeginGetCredentialResponse.Builder "View this page in Java")

<br />

```
class BeginGetCredentialResponse.Builder
```

<br />

*** ** * ** ***

Builder for[BeginGetCredentialResponse](https://developer.android.com/reference/kotlin/androidx/credentials/provider/BeginGetCredentialResponse).

## Summary

|                                                         ### Public constructors                                                          |
|------------------------------------------------------------------------------------------------------------------------------------------|
| [Builder](https://developer.android.com/reference/kotlin/androidx/credentials/provider/BeginGetCredentialResponse.Builder#Builder())`()` |

|                                                                 ### Public functions                                                                  |
|-------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [BeginGetCredentialResponse.Builder](https://developer.android.com/reference/kotlin/androidx/credentials/provider/BeginGetCredentialResponse.Builder) | [addAction](https://developer.android.com/reference/kotlin/androidx/credentials/provider/BeginGetCredentialResponse.Builder#addAction(androidx.credentials.provider.Action))`(action: `[Action](https://developer.android.com/reference/kotlin/androidx/credentials/provider/Action)`)` Adds an[Action](https://developer.android.com/reference/kotlin/androidx/credentials/provider/Action)to the list of actions to be displayed on the UI.                                                                                               |
| [BeginGetCredentialResponse.Builder](https://developer.android.com/reference/kotlin/androidx/credentials/provider/BeginGetCredentialResponse.Builder) | [addAuthenticationAction](https://developer.android.com/reference/kotlin/androidx/credentials/provider/BeginGetCredentialResponse.Builder#addAuthenticationAction(androidx.credentials.provider.AuthenticationAction))`(authenticationAction: `[AuthenticationAction](https://developer.android.com/reference/kotlin/androidx/credentials/provider/AuthenticationAction)`)` Add an authentication entry to be shown on the UI.                                                                                                              |
| [BeginGetCredentialResponse.Builder](https://developer.android.com/reference/kotlin/androidx/credentials/provider/BeginGetCredentialResponse.Builder) | [addCredentialEntry](https://developer.android.com/reference/kotlin/androidx/credentials/provider/BeginGetCredentialResponse.Builder#addCredentialEntry(androidx.credentials.provider.CredentialEntry))`(entry: `[CredentialEntry](https://developer.android.com/reference/kotlin/androidx/credentials/provider/CredentialEntry)`)` Adds a[CredentialEntry](https://developer.android.com/reference/kotlin/androidx/credentials/provider/CredentialEntry)to the list of entries to be displayed on the UI.                                  |
| [BeginGetCredentialResponse](https://developer.android.com/reference/kotlin/androidx/credentials/provider/BeginGetCredentialResponse)                 | [build](https://developer.android.com/reference/kotlin/androidx/credentials/provider/BeginGetCredentialResponse.Builder#build())`()` Builds a[BeginGetCredentialResponse](https://developer.android.com/reference/kotlin/androidx/credentials/provider/BeginGetCredentialResponse)instance.                                                                                                                                                                                                                                                 |
| [BeginGetCredentialResponse.Builder](https://developer.android.com/reference/kotlin/androidx/credentials/provider/BeginGetCredentialResponse.Builder) | [setActions](https://developer.android.com/reference/kotlin/androidx/credentials/provider/BeginGetCredentialResponse.Builder#setActions(kotlin.collections.List))`(actions: `[List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)`<`[Action](https://developer.android.com/reference/kotlin/androidx/credentials/provider/Action)`>)` Sets the list of actions to be displayed on the UI.                                                                                                              |
| [BeginGetCredentialResponse.Builder](https://developer.android.com/reference/kotlin/androidx/credentials/provider/BeginGetCredentialResponse.Builder) | [setAuthenticationActions](https://developer.android.com/reference/kotlin/androidx/credentials/provider/BeginGetCredentialResponse.Builder#setAuthenticationActions(kotlin.collections.List))`(` ` authenticationEntries: `[List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)`<`[AuthenticationAction](https://developer.android.com/reference/kotlin/androidx/credentials/provider/AuthenticationAction)`>` `)` Sets the list of authentication entries to be displayed on the account selector UI. |
| [BeginGetCredentialResponse.Builder](https://developer.android.com/reference/kotlin/androidx/credentials/provider/BeginGetCredentialResponse.Builder) | [setCredentialEntries](https://developer.android.com/reference/kotlin/androidx/credentials/provider/BeginGetCredentialResponse.Builder#setCredentialEntries(kotlin.collections.List))`(entries: `[List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)`<`[CredentialEntry](https://developer.android.com/reference/kotlin/androidx/credentials/provider/CredentialEntry)`>)` Sets the list of credential entries to be displayed on the account selector UI.                                            |
| [BeginGetCredentialResponse.Builder](https://developer.android.com/reference/kotlin/androidx/credentials/provider/BeginGetCredentialResponse.Builder) | [setRemoteEntry](https://developer.android.com/reference/kotlin/androidx/credentials/provider/BeginGetCredentialResponse.Builder#setRemoteEntry(androidx.credentials.provider.RemoteEntry))`(remoteEntry: `[RemoteEntry](https://developer.android.com/reference/kotlin/androidx/credentials/provider/RemoteEntry)`?)` Sets a remote credential entry to be shown on the UI.                                                                                                                                                                |

## Public constructors

### Builder

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

```
Builder()
```  

## Public functions

### addAction

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

```
fun addAction(action: Action): BeginGetCredentialResponse.Builder
```

Adds an[Action](https://developer.android.com/reference/kotlin/androidx/credentials/provider/Action)to the list of actions to be displayed on the UI.

An \[Action\] must be used for independent user actions, such as opening the app, intenting directly into a certain app activity etc. The pending intent set with the \[action\] must invoke the corresponding activity.  

### addAuthenticationAction

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

```
fun addAuthenticationAction(authenticationAction: AuthenticationAction): BeginGetCredentialResponse.Builder
```

Add an authentication entry to be shown on the UI. Providers must set this entry if the corresponding account is locked and no underlying credentials can be returned.

When the user selects this \[authenticationAction\], the system invokes the corresponding pending intent. Once the authentication action activity is launched, and the user is authenticated, providers should create another response with \[BeginGetCredentialResponse\] using this time adding the unlocked credentials in the form of \[CredentialEntry\]'s.

The new response object must be set on the authentication activity's result. The result code should be set to \[android.app.Activity#RESULT_OK\] and the \[CredentialProviderService#EXTRA_BEGIN_GET_CREDENTIAL_RESPONSE\] extra should be set with the new fully populated \[BeginGetCredentialResponse\] object.  

### addCredentialEntry

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

```
fun addCredentialEntry(entry: CredentialEntry): BeginGetCredentialResponse.Builder
```

Adds a[CredentialEntry](https://developer.android.com/reference/kotlin/androidx/credentials/provider/CredentialEntry)to the list of entries to be displayed on the UI.  

### build

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

```
fun build(): BeginGetCredentialResponse
```

Builds a[BeginGetCredentialResponse](https://developer.android.com/reference/kotlin/androidx/credentials/provider/BeginGetCredentialResponse)instance.  

### setActions

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

```
fun setActions(actions: List<Action>): BeginGetCredentialResponse.Builder
```

Sets the list of actions to be displayed on the UI.  

### setAuthenticationActions

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

```
fun setAuthenticationActions(
    authenticationEntries: List<AuthenticationAction>
): BeginGetCredentialResponse.Builder
```

Sets the list of authentication entries to be displayed on the account selector UI.  

### setCredentialEntries

```
fun setCredentialEntries(entries: List<CredentialEntry>): BeginGetCredentialResponse.Builder
```

Sets the list of credential entries to be displayed on the account selector UI.  

### setRemoteEntry

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

```
fun setRemoteEntry(remoteEntry: RemoteEntry?): BeginGetCredentialResponse.Builder
```

Sets a remote credential entry to be shown on the UI. Provider must set this if they wish to get the credential from a different device.

When constructing the[CredentialEntry](https://developer.android.com/reference/kotlin/androidx/credentials/provider/CredentialEntry)object, the pending intent must be set such that it leads to an activity that can provide UI to fulfill the request on a remote device. When user selects this[remoteEntry](https://developer.android.com/reference/kotlin/androidx/credentials/provider/BeginGetCredentialResponse.Builder#setRemoteEntry(androidx.credentials.provider.RemoteEntry)), the system will invoke the pending intent set on the[CredentialEntry](https://developer.android.com/reference/kotlin/androidx/credentials/provider/CredentialEntry).

Once the remote credential flow is complete, the \[android.app.Activity\] result should be set to \[android.app.Activity#RESULT_OK\] and an extra with the \[CredentialProviderService#EXTRA_GET_CREDENTIAL_RESPONSE\] key should be populated with a \[android.credentials.Credential\] object.

Note that as a provider service you will only be able to set a remote entry if : - Provider service possesses the \[android.Manifest.permission.PROVIDE_REMOTE_CREDENTIALS\] permission. - Provider service is configured as the provider that can provide remote entries.

If the above conditions are not met, setting back[BeginGetCredentialResponse](https://developer.android.com/reference/kotlin/androidx/credentials/provider/BeginGetCredentialResponse)on the callback from CredentialProviderService#onBeginGetCredential will throw a[SecurityException](https://developer.android.com/reference/java/lang/SecurityException.html).