# DigitalCredential

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

*** ** * ** ***

<br />

```
@ExperimentalDigitalCredentialApi
class DigitalCredential : Credential
```

<br />

|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) |||
| ↳ | [androidx.credentials.Credential](https://developer.android.com/reference/kotlin/androidx/credentials/Credential) ||
|   | ↳ | [androidx.credentials.DigitalCredential](https://developer.android.com/reference/kotlin/androidx/credentials/DigitalCredential) |

*** ** * ** ***

Represents the user's digital credential, generally used for verification or sign-in purposes.

Notice, this class does not necessarily always represents a successful digital credential. Depending on the protocol in your request, the `https://developer.android.com/reference/kotlin/androidx/credentials/DigitalCredential#credentialJson()` may contain a failure response generated from the provider. Therefore, please follow the protocol specification to parse the `https://developer.android.com/reference/kotlin/androidx/credentials/DigitalCredential#credentialJson()` and determine the failure / success response. For example, [here](https://openid.net/specs/openid-4-verifiable-presentations-1_0.html#name-error-response) is the error response definition for the OpenID for Verifiable Presentations protocol.

When you make an OpenID4VP request for multiple credentials, you may receive a `https://developer.android.com/reference/kotlin/androidx/credentials/GetCredentialResponse` containing a list of `https://developer.android.com/reference/kotlin/androidx/credentials/DigitalCredential`. These credentials may be aggregated from one or more providers. Because some responses may contain an OpenID4VP error, you should check each individual `https://developer.android.com/reference/kotlin/androidx/credentials/DigitalCredential` to ensure it satisfies your overall request.

NOTE: For non-protocol errors (system-level infrastructure failures, provider crashes, or generic CredMan exceptions), the transaction will NOT return any partial credentials at all. Such failures trigger an immediate transaction abort where zero credentials are yielded.

## Summary

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/credentials/DigitalCredential#TYPE_DIGITAL_CREDENTIAL()` The type value for public key credential related operations. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/credentials/DigitalCredential#DigitalCredential(kotlin.String)(credentialJson: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Constructs a `DigitalCredential`. |

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/credentials/DigitalCredential#credentialJson()` the digital credential in the JSON format; the latest format is defined at https://wicg.github.io/digital-credentials/#the-digitalcredential-interface |

### Inherited properties

From [androidx.credentials.Credential](https://developer.android.com/reference/kotlin/androidx/credentials/Credential) `https://developer.android.com/reference/android/os/Bundle.html` `https://developer.android.com/reference/kotlin/androidx/credentials/Credential#data()`

the credential data in the `https://developer.android.com/reference/android/os/Bundle.html` format
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` `https://developer.android.com/reference/kotlin/androidx/credentials/Credential#type()`

the credential type determined by the credential-type-specific subclass (e.g. `https://developer.android.com/reference/kotlin/androidx/credentials/PasswordCredential#TYPE_PASSWORD_CREDENTIAL()` for `PasswordCredential` or `https://developer.android.com/reference/kotlin/androidx/credentials/PublicKeyCredential#TYPE_PUBLIC_KEY_CREDENTIAL()` for `PublicKeyCredential`)

## Constants

### TYPE_DIGITAL_CREDENTIAL

```
const val TYPE_DIGITAL_CREDENTIAL: String
```

The type value for public key credential related operations.

## Public constructors

### DigitalCredential

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

```
DigitalCredential(credentialJson: String)
```

Constructs a `DigitalCredential`.

| Parameters |
|---|---|
| `credentialJson: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | the digital credential in the JSON format; the latest format is defined at https://wicg.github.io/digital-credentials/#the-digitalcredential-interface |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if the `credentialJson` is not a valid json |

## Public properties

### credentialJson

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

```
val credentialJson: String
```

the digital credential in the JSON format; the latest format is defined at https://wicg.github.io/digital-credentials/#the-digitalcredential-interface