DigitalCredential


@ExperimentalDigitalCredentialApi
public final class DigitalCredential extends Credential


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 credentialJson may contain a failure response generated from the provider. Therefore, please follow the protocol specification to parse the credentialJson and determine the failure / success response. For example, here 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 GetCredentialResponse containing a list of DigitalCredential. These credentials may be aggregated from one or more providers. Because some responses may contain an OpenID4VP error, you should check each individual 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

static final @NonNull String

The type value for public key credential related operations.

Public constructors

DigitalCredential(@NonNull String credentialJson)

Constructs a DigitalCredential.

Public methods

final @NonNull String

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

Inherited methods

From androidx.credentials.Credential
final @NonNull Bundle

the credential data in the Bundle format

final @NonNull String

the credential type determined by the credential-type-specific subclass (e.g. PasswordCredential.TYPE_PASSWORD_CREDENTIAL for PasswordCredential or PublicKeyCredential.TYPE_PUBLIC_KEY_CREDENTIAL for PublicKeyCredential)

Constants

TYPE_DIGITAL_CREDENTIAL

public static final @NonNull String TYPE_DIGITAL_CREDENTIAL

The type value for public key credential related operations.

Public constructors

DigitalCredential

Added in 1.5.0
public DigitalCredential(@NonNull String credentialJson)

Constructs a DigitalCredential.

Parameters
@NonNull String credentialJson

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

Throws
IllegalArgumentException

if the credentialJson is not a valid json

Public methods

getCredentialJson

Added in 1.5.0
public final @NonNull String getCredentialJson()

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