retrieveCredentials

suspend fun retrieveCredentials(    activity: Activity,     credentialOffer: String,     clientId: String,     transactionCode: String? = null): List<RetrieveCredentialResult>
  1. Retrieves credentials from the issuer, as defined by OpenID4VCI specification.

  2. Validates the retrieved credentials as per ISO/IEC 18013-5:2021, using the same set of validations, as described in addCredential.

  3. Securely stores the credentials on the device.

A failure to retrieve, validate, or save a credential will NOT automatically cause a failure of other credential requests.

If an issue, related to the whole offer, occurs, the function will throw an exception.

If an issue, related to downloading, validating, or saving a single credential occurs, this will be reflected in the returned list of RetrieveCredentialResult objects.

Return

A list of RetrieveCredentialResult objects. Each result contains a RetrieveCredentialResult.doctype, and either a local ID of a retrieved credential, or an error, associated with the retrieval.

Parameters

activity

An Activity from where this function is called. The activity's context is required to show the embedded browser with the user consent form, if the Authorization Code Flow is used. Also, it is required in both code flows to create a biometric authentication prompt for secure device key generation. The SDK does not store the activity after this function returns.

credentialOffer

URL-encoded credential offer. It is received from the issuer, e.g., using the QR code. Currently only offer by value is supported.

clientId

The identifier that is registered with the issuer as a trusted wallet application.

transactionCode

Transaction code for the Pre-Authorized Code Flow. Based on the offer, a transaction code can be required to prove the user's identity. If you don't know if the issuer requires a transaction code, you can check it using discoverCredentialOffer function to adjust your UI accordingly.

Throws

If the SDK is not initialized before calling this function. See: initialize.

If there was a network connection issue during any network call in this function.

If the credential offer discovery process fails for any reason, other than those listed above. For instance, if there was an unexpected response from the server when requesting the issuer's metadata.

If the transaction code is not aligned with the format, expected by the issuer.

If the offer can be used only with Authorization Code Flow, but the redirect URI was not specified during the SDK initialization.

If there was an issue, other than those listed above, that caused a failure of the whole retrieval process.