# GetCredentialResponse

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

*** ** * ** ***

<br />

```
public final class GetCredentialResponse
```

<br />

*** ** * ** ***

Encapsulates the result of a user credential request.

Typically, a response contains a single user credential in `https://developer.android.com/reference/androidx/credentials/GetCredentialResponse#credential()` (such as a passkey or a password). However, for `https://developer.android.com/reference/androidx/credentials/DigitalCredential`s, a single request may yield multiple credentials returned in `https://developer.android.com/reference/androidx/credentials/GetCredentialResponse#credentials()`.

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

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/credentials/GetCredentialResponse#GetCredentialResponse(androidx.credentials.Credential)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/Credential credential)` Constructs a `https://developer.android.com/reference/androidx/credentials/GetCredentialResponse` containing a single credential. |
| `https://developer.android.com/reference/androidx/credentials/GetCredentialResponse#GetCredentialResponse(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/Credential> credentials)` |

| ### Public methods |
|---|---|
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/Credential` | `https://developer.android.com/reference/androidx/credentials/GetCredentialResponse#getCredential()()` The user credential that can be used to authenticate to your app. |
| `final @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/Credential>` | `https://developer.android.com/reference/androidx/credentials/GetCredentialResponse#getCredentials()()` the list of user credentials returned by the provider(s) that can be used to authenticate to your app |

## Public constructors

### GetCredentialResponse

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

```
public GetCredentialResponse(@NonNull Credential credential)
```

Constructs a `https://developer.android.com/reference/androidx/credentials/GetCredentialResponse` containing a single credential.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/Credential credential` | the user credential that can be used to authenticate to your app |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-null-pointer-exception/index.html` | If `https://developer.android.com/reference/androidx/credentials/GetCredentialResponse#(androidx.credentials.Credential)` is null |

### GetCredentialResponse

```
public GetCredentialResponse(@NonNull List<@NonNull Credential> credentials)
```

## Public methods

### getCredential

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

```
public final @NonNull Credential getCredential()
```

The user credential that can be used to authenticate to your app.

When multiple credentials are returned in `https://developer.android.com/reference/androidx/credentials/GetCredentialResponse#credentials()`, this returns the first credential.

### getCredentials

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

```
public final @NonNull List<@NonNull Credential> getCredentials()
```

the list of user credentials returned by the provider(s) that can be used to authenticate to your app