createCredential

suspend fun createCredential(tokenResponse: TokenResponseParameters, metadata: IssuerMetadata, credentialFormat: SupportedCredentialFormat, clientNonce: String? = null, previouslyRequestedScope: String? = null, clientId: String = defaultClientId): KmmResult<Collection<OpenId4VciClient.CredentialRequest>>(source)

Creates the credential request to be sent to the credential issuer. Send each request with OpenId4VciProtocolClient.credentialRequest, which adds the access token from tokenResponse and, for DPoP-bound tokens, the DPoP proof, and parses the response.

Creates all requests with the same clientNonce. With a credential issuer that accepts each c_nonce only once, use prepareCredentialRequests, and create each request with its own c_nonce with the overload accepting a PreparedCredentialRequest instead.

Parameters

tokenResponse

from the authorization server token endpoint

metadata

the issuer's metadata, see IssuerMetadata

credentialFormat

which credential to request (needed to build the correct proof)

clientNonce

if required by the issuer (see IssuerMetadata.nonceEndpointUrl), the value from there, exactly ClientNonceResponse.clientNonce

previouslyRequestedScope

the scope value requested in the token request, since the authorization server may not set it in tokenResponse

clientId

the client_id of the OAuth 2.0 client, used as the issuer of proof JWTs


suspend fun createCredential(metadata: IssuerMetadata, credentialConfigurationId: String, clientNonce: String? = null, clientId: String = defaultClientId): KmmResult<OpenId4VciClient.CredentialRequest>(source)

Creates the credential request for exactly one credential, to be sent to the credential issuer. Send it with OpenId4VciProtocolClient.credentialRequest, which adds the access token and, for DPoP-bound tokens, the DPoP proof, and parses the response.

Only use this when the token response did not contain credential_identifiers in its authorization_details, because then credential_configuration_id MUST NOT be used (OID4VCI 1.0 Section 8.2), see CredentialRequestParameters.credentialConfigurationId. Otherwise, use the overload accepting TokenResponseParameters.

Parameters

metadata

the issuer's metadata, see IssuerMetadata

credentialConfigurationId

the exact credential_configuration_id to request, one of the keys from IssuerMetadata.supportedCredentialConfigurations

clientNonce

if required by the issuer (see IssuerMetadata.nonceEndpointUrl), the value from there, exactly ClientNonceResponse.clientNonce

clientId

the client_id of the OAuth 2.0 client, used as the issuer of proof JWTs


suspend fun createCredential(request: OpenId4VciClient.PreparedCredentialRequest, metadata: IssuerMetadata, clientNonce: String? = null, clientId: String = defaultClientId): KmmResult<OpenId4VciClient.CredentialRequest>(source)

Creates the credential request for request, prepared with prepareCredentialRequests, with a proof for its PreparedCredentialRequest.credentialFormat (see ProofCreator) and, if the credential issuer supports it, the encryption of request and response (OpenID4VCI 1.0, 10). Create it right before sending it with OpenId4VciProtocolClient.credentialRequest, each with a fresh clientNonce, as the credential issuer decides how long a c_nonce can be used (13.8), and may accept each one only once.

Parameters

request

one of the requests from prepareCredentialRequests

metadata

the issuer's metadata, see IssuerMetadata

clientNonce

if required by the issuer (see IssuerMetadata.nonceEndpointUrl), the value from there, exactly ClientNonceResponse.clientNonce

clientId

the client_id of the OAuth 2.0 client, used as the issuer of proof JWTs