createCredentialRequest
suspend fun createCredentialRequest(input: WalletService.CredentialRequestInput, clientNonce: String?, credentialIssuer: String?): KmmResult<CredentialRequestParameters>(source)
Send the result as JSON-serialized content to the server at /credential
(or more specific IssuerMetadata.credentialEndpointUrl).
Also send along the TokenResponseParameters.accessToken from the token response in HTTP header Authorization
as value Bearer accessTokenValue
(depending on the TokenResponseParameters.tokenType).
Be sure to include a DPoP header if TokenResponseParameters.tokenType is DPoP
, see JwsService.buildDPoPHeader.
See OAuth2Client.createTokenRequestParameters.
Sample ktor code:
val token = ...
val credentialRequest = client.createCredentialRequest(
requestOptions = requestOptions,
clientNonce = token.clientNonce,
credentialIssuer = issuerMetadata.credentialIssuer
).getOrThrow()
val credentialResponse = httpClient.post(issuerMetadata.credentialEndpointUrl) {
setBody(credentialRequest)
headers {
append(HttpHeaders.Authorization, "Bearer ${token.accessToken}")
}
}
Content copied to clipboard
Parameters
input
which credential to request, see subclasses of CredentialRequestInput
clientNonce
c_nonce
from the token response, optional string, see TokenResponseParameters.clientNonce
credentialIssuer
credential_issuer
from the metadata, see IssuerMetadata.credentialIssuer