Issuing to a wallet (OpenID4VCI)
Riley has passed Cedar's data-handling course, and the training portal offers to add it to their walletAn application that holds a person's verifiable credentials and the keys that go with them, receives credentials from issuers, and presents them to verifiers when the person agrees.. This lesson follows that issuance with OpenID4VCI: who decides that Riley earned the credential, how an offer differs from the credential, how the wallet proves the key the credential will name, and why delivery is a lifecycle with pending and lost replies.
The offer and the credential are different
The QR code carries a credential offer. Decoded, Riley's looks like this:
{
"credential_issuer": "https://credentials.cedar.example",
"credential_configuration_ids": ["cedar-course"],
"grants": {
"urn:ietf:params:oauth:grant-type:pre-authorized_code": {
"pre-authorized_code": "rpKEjUObM8ThjXroWcy9ftUw0w5r0fyZ",
"tx_code": {
"input_mode": "numeric",
"length": 6,
"description": "Enter the code Cedar emailed to [email protected]"
}
}
}
}The offer names the issuer and the configuration on offer, and says how the wallet can obtain authorization. It is not the credential, and it does not prove anything to anyone. Cedar's issuance runs through five stages, and keeping them apart makes each failure easier to place:
- Course decision: Cedar decides what Riley has earned.
- Offer: names the issuer and the offered configuration.
- Authorization: gives the wallet authority to collect it, through a pre-authorized code or an authorization codeA short-lived, single-use value that the authorization server sends back to a client through the browser. The client swaps it for tokens in a direct request to the authorization server; APIs never accept it..
- Credential request: the wallet asks for the credential, with the key proof the configuration requires.
- Credential response: the delivered result, which the wallet validates and stores.
Riley's offer uses the pre-authorized code grant. Cedar already knows who Riley is, because they are signed in to the training portal, so it mints a code tied to their course record and puts it in the offer. The wallet does not need to send them through a sign-in page again; it exchanges the code directly at Cedar's token endpointThe authorization server address where clients exchange an authorization code, refresh token, or other grant for tokens, in a direct request rather than through a browser redirect..
That convenience has a cost. Whoever holds the offer holds the code. A colleague glancing at Riley's screen, or a forwarded screenshot, could scan the same QR code. The tx_code object is Cedar's protection against that: it tells the wallet that the token request also needs a six-digit transaction code, and Cedar sends that code to Riley's email rather than putting it in the QR code. The pre-authorized code alone is not enough. Cedar also accepts each code only once, and only for a short time.
POST /token HTTP/1.1
Host: login.cedar.example
Content-Type: application/x-www-form-urlencoded
grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Apre-authorized_code
&pre-authorized_code=rpKEjUObM8ThjXroWcy9ftUw0w5r0fyZ
&tx_code=493536
HTTP/1.1 200 OK
Content-Type: application/json
Cache-Control: no-store
{
"access_token": "JmUSA_GR5oRydzuynUykQ4bruIlD9PnZ",
"token_type": "Bearer",
"expires_in": 3600
}The offer could instead have carried an authorization_code grant with an issuer_state value. The wallet would then send Riley through Cedar's ordinary sign-in, passing issuer_state back in the authorization request so Cedar can connect that sign-in to the offer it made. That suits a wallet that starts the flow on its own, or an issuer that wants to see the person sign in at the moment of issuance.
Bind the request to its purpose
The access token lets the wallet do one thing: collect the cedar-course credential from Cedar's credential endpoint. It is not a presentation Riley can show Northwind, and it is not a general Cedar token. If the wallet asked for a different configuration with it, Cedar should refuse.
The credential also needs a holder key, the cnf key Northwind will later check. The wallet generates a key pairA private key and a public key generated together and mathematically linked. The private key creates signatures and the public key checks them, but the private key cannot practically be worked out from the public one. and proves it holds the private half. First it asks Cedar's nonce endpoint for a fresh value, then it signs a key proof that includes it:
POST /nonce HTTP/1.1
Host: credentials.cedar.example
HTTP/1.1 200 OK
Cache-Control: no-store
{ "c_nonce": "S1yI08mmbB4xciZjy6x0zQ" }
Key proof header
{
"typ": "openid4vci-proof+jwt",
"alg": "ES256",
"jwk": {
"kty": "EC",
"crv": "P-256",
"x": "HUHZ44gDzvw4dKiztjfbdX4GkPgE6eKHu3r3f1wgfa4",
"y": "aA19bcDxYdJl4ALGshINuCEjHSA-O_Z9UQOI6uhDhRU"
}
}
Key proof payload
{
"aud": "https://credentials.cedar.example",
"iat": 1790949580,
"nonce": "S1yI08mmbB4xciZjy6x0zQ"
}
POST /credential HTTP/1.1
Host: credentials.cedar.example
Authorization: Bearer JmUSA_GR5oRydzuynUykQ4bruIlD9PnZ
Content-Type: application/json
{
"credential_configuration_id": "cedar-course",
"proofs": {
"jwt": ["eyJ0eXAiOiJvcGVuaWQ0dmNpLXByb29mK2p3dCIs..."]
}
}The proof's typ marks it as an OpenID4VCI key proof, so it cannot be mistaken for any other JWT signed with the same key. Its aud names Cedar's credential issuer and its nonce is the one Cedar just handed out, so a proof made for another issuer, or recorded from an earlier request, fails. The proof has no iss claim, because a wallet using a pre-authorized code without a client identifier leaves it out. Cedar verifies the signature with the key in the header, and if it issues the credential, that key becomes the cnf key inside it.
| The proof establishes | The proof does not establish |
|---|---|
| The requester controls the private key matching the public key in the header | That the requester is Riley |
| The proof was made for Cedar's credential issuer | That anyone has earned the cedar-course credential |
| The proof was made after Cedar issued this nonce | How well the phone protects the key, which needs separate evidence |
The right-hand column is where wrong-person issuance hides. A wallet can prove it holds a key without proving that it belongs to Riley, rather than to someone who scanned their offer. Cedar therefore takes the credential's subject from the course record the pre-authorized code was minted for, never from anything the wallet sends, and issues it only if that record says the course was passed. The key proof answers which key the credential will name. Cedar's own records answer whether to issue it at all, and to whom.
Delivery is a lifecycle
Often the credential endpoint answers at once with HTTP 200 and the credential in a credentials array. Sometimes Cedar cannot produce it immediately, perhaps because its signing service queues requests at busy times. Then it answers with a deferred response:
HTTP/1.1 202 Accepted
Content-Type: application/json
{
"transaction_id": "Z9scgMdj8ppe2b9c",
"interval": 300
}
Five minutes later:
POST /deferred HTTP/1.1
Host: credentials.cedar.example
Authorization: Bearer JmUSA_GR5oRydzuynUykQ4bruIlD9PnZ
Content-Type: application/json
{ "transaction_id": "Z9scgMdj8ppe2b9c" }
HTTP/1.1 200 OK
Content-Type: application/json
{
"credentials": [
{ "credential": "eyJhbGciOiJFUzI1NiIsInR5cCI6ImRjK3NkLWp3...~WyIyR0xD...~WyJpVkdq...~WyJGVDY1...~" }
],
"notification_id": "rJK5SEdyt2ad"
}The 202 is neither a failure nor a delivery. Cedar has accepted the request and owes the wallet a credential; the wallet waits at least interval seconds and asks again with the transaction_id. Reporting this moment as "issued" would be wrong, and so would reporting it as "failed" and inviting Riley to start over. The deferred request also carries the same access token, which is why Cedar issued that token for an hour rather than a few minutes. A token that expired while the credential was still pending would leave the wallet unable to collect it, so an issuer that defers sizes the token lifetime to cover the wait, or issues a refresh token alongside it.
Starting over is exactly what goes wrong when a connection drops. If Riley's phone loses signal after sending the credential request, the wallet cannot tell whether Cedar received it, and its retry should not leave Cedar signing two credentials for one course result. Cedar keeps one record per issuance and answers a repeat with the existing transaction rather than starting a new one. That record holds what is needed to reconcile: the course record, the configuration, the state of the transaction, and safe references. It does not hold the raw pre-authorized code, transaction code, access token or key proof, which could be replayed by anyone reading the logs.
| Time | Event | What Cedar knows afterwards |
|---|---|---|
| 13:58 | Offer shown; transaction code emailed | An invitation exists. Nothing is authorized or delivered |
| 13:59 | Pre-authorized code redeemed with the transaction code | The code is used up; a second redemption must fail |
| 13:59 | Credential request with key proof; 202 returned | The wallet controls the key; the credential is pending |
| 14:05 | Deferred request returns the credential | The credential was sent to the wallet |
| 14:05 | Wallet reports credential_accepted to the notification endpoint | The wallet says it validated and stored the credential |
The wallet has its own checks before that last row. It verifies Cedar's signature with keys from Cedar's metadata, confirms the cnf key is the one it proved, and checks that the disclosures match the digests. Only then does it store the credential, under the same protection as its keys, and tell Cedar it was accepted. Had validation failed, it would report credential_failure instead.
Notice what the training portal knows throughout: that Riley signed in and clicked a button. A successful browser sign-in at 13:58 says nothing about whether a wallet holds the credential at 14:05. Only the issuance record, and the wallet's own report, can say that.
Check your understanding
Try these questions before moving on. If an answer isn't right, use the feedback and try again.
Try it in the Lab
- Check an OpenID4VCI offer, key proof and issued credentialDecode Cedar's credential offer, check the wallet's key proof as the issuer would, confirm the issued SD-JWT VC names the proved key, then see a replayed proof and a look-alike issuer's proof refused.