Credential claiming mDocs Holder SDK Cheatsheet
This cheatsheet provides an overview of how to use the MATTR mDocs Holder SDKs to claim mDocs issued through an OID4VCI workflow.
Use these guides as a quick reference to get started. For detailed information, explore the tutorials and reference documentation tailored for each platform.
Core usage
Initialize the SDK
try mobileCredentialHolder.initialize(
userAuthenticationConfiguration: UserAuthenticationConfiguration(
userAuthenticationBehavior: .always,
userAuthenticationType: .biometricOrPasscode,
presentationTimeoutSeconds: 20
),
credentialIssuanceConfiguration: CredentialIssuanceConfiguration(
redirectUri: "<WalletRedirectUri>",
autoTrustMobileCredentialIaca: true
)
)
userAuthenticationConfiguration
: Optional. Configures when the SDK requires user authentication to access or present credentials. The example shows the default values. Refer to the reference documentation for additional details about the available configuration options.redirectUri
: Provide a URL that corresponds to a specific path in your application. The SDK will redirect the user to this path after they successfully complete authentication. Required for theAuthorization Code flow
.autoTrustMobileCredentialIaca
: Set totrue
if you trust the credential issuer(s) for any offer. Defaults tofalse
.
mobileCredentialHolder.initialize(
activity,
userAuthenticationConfiguration = UserAuthenticationConfiguration(
behavior = UserAuthenticationBehavior.Always,
presentationTimeoutSeconds = 20
),
credentialIssuanceConfiguration = CredentialIssuanceConfiguration(
redirectUri = "<WalletRedirectUri>",
autoTrustMobileCredentialIaca = true
)
)
userAuthenticationConfiguration
: Optional. Configures when the SDK requires user authentication to access or present credentials. The example shows the default values. Refer to the reference documentation for additional details about the available configuration options.redirectUri
: Provide a URL that corresponds to a specific path in your application. The SDK will redirect the user to this path after they successfully complete authentication. Required for theAuthorization Code flow
.autoTrustMobileCredentialIaca
: Set totrue
if you trust the credential issuer(s) for any offer. Defaults tofalse
.
const initialiseResult = await mobileCredentialHolder.initialise()
if (initialiseResult.isErr()) {
const { error } = initialiseResult
// handle error scenarios
return
}
Discover credential offer
let discoveredOffer = try await mobileCredentialHolder.discoverCredentialOffer(offerUrl: String)
offerUrl
: Pass the OID4VCI initiation URL.
The
discoverCredentialOffer
method returns a
DiscoveredCredentialOffer
object containing the offer details.
val discoveredOffer = mobileCredentialHolder.discoverCredentialOffer(offerUri)
offerUrl
: Pass the OID4VCI initiation URL as a string.
The
discoverCredentialOffer
method returns an instance of
DiscoveredCredentialOffer
containing the offer details.
const discoveredOfferResult = await mobileCredentialHolder.discoverCredentialOffer(offerUrl)
if (discoveredOfferResult.isErr()) {
const { error } = discoveredOfferResult
// handle error scenarios
return
}
const credentialOffer = discoveredOfferResult.value
offerUrl
: Pass the OID4VCI initiation URL.
The discoverCredentialOffer
method returns a Result<
CredentialOfferResponse, Error>
(using the
neverthrow
pattern) object containing the offer
details and/or any errors.
Claim and store credentials
let retrievedCredentialResults = try await mobileCredentialHolder.retrieveCredentials(
credentialOffer: String,
clientId: "<WalletClientID>",
transactionCode: nil
)
credentialOffer
: Pass the OID4VCI credential offer URI.clientId
: Pass a string that identifies your wallet application with the issuer.transactionCode
: Provide a transaction code if thePre-Authorization Code flow
offer requires a transaction code.
The
retrieveCredentials
method returns an array of
RetrieveCredentialResult
objects, each containing the metadata of the retrieved credentials, including the credential ID
(credentialId
).
val credentialResults = mobileCredentialHolder.retrieveCredentials(
activity = activity,
credentialOffer = offerUri,
clientId = "<WalletClientID>",
transactionCode = null
)
credentialOffer
: Pass the OID4VCI credential offer URI.clientId
: Pass a string that identifies your wallet application with the issuer.transactionCode
: Provide a transaction code if claiming a credential using aPre-authorized Code flow
that requires a transaction code.
The
retrieveCredentials
method returns an array of
RetrieveCredentialResult
objects, each containing the metadata of the retrieved credentials, including the credential ID
(credentialId
).
const retrievedCredentialsResults = await mobileCredentialHolder.retrieveCredentials({
credentialOffer,
clientId: '<WalletClientID>',
redirectUri: '<WalletDeepLink>',
autoTrustMobileIaca: true
})
if (retrievedCredentialsResults.isErr()) {
const { error } = retrievedCredentialsResults
// handle error scenarios
return
}
const retrievedCredentials = retrievedCredentialsResults.value
const retrievedCredential = retrievedCredentials[0]
if (retrievedCredential?.error || !retrievedCredential?.credentialId) {
// handle error scenarios
return
}
const credentialId = retrievedCredential.credentialId
credentialOffer
: Pass the discovered credential offer object.clientId
: Pass a string that identifies your wallet application with the issuer.redirectUri
: Provide a URL that corresponds to a specific path in your application. The SDK will redirect the user to this path after they successfully complete authentication. Required for theAuthorization Code flow
.autoTrustMobileIaca
: Set totrue
if you want the SDK to trust the credential issuer(s) for any offer. Defaults tofalse
.
The retrieveCredentials
method returns a Result<
RetrieveCredentialsResponse, Error>
(using the
neverthrow
pattern) object containing the metadata of
the retrieved credentials, including the credential ID (credentialId
).
Access credential
let credential = try mobileCredentialHolder.getCredential(credentialId: String)
credentialId
: Pass the credential ID of the credential you want to access.
val credential = mobileCredentialHolder.getCredential(credentialId)
credentialId
: Pass the credential ID of the credential you want to access, as a string.
const credentialResult = await mobileCredentialHolder.getCredential(credentialId)
if (credentialResult.isErr()) {
const { error } = credentialResult
// handle error scenarios
return
}
const credential = credentialResult.value
credentialId
: Pass the credential ID of the credential you want to access.
How would you rate this page?