Authorization Code Flow
This flow covers your application creating a credential offer, the wallet redirecting the holder to an external IdP to authenticate, and the Issuer2 Service mapping the returned ID token claims into the credential. Set "authMethod": "AUTHORIZED" when creating the offer to use it.
Components involved:
- Your Application — creates the credential offer and displays the QR code.
- Wallet (Holder) — scans the QR code, redirects the holder to log in, completes the flow.
- Issuer2 Service — manages the issuance session, correlates
issuer_state, appliesidTokenClaimsMapping, and signs the credential. - External IdP — authenticates the holder and issues the ID token, configured via
authProviderConfigurationon the issuer service.
This flow requires an external OAuth/OIDC provider configured via authProviderConfiguration when creating the issuer service before you create an AUTHORIZED offer.
Loading diagram...
This diagram is a simplified overview focused on how the Issuer2 Service behaves. It omits some protocol details (e.g. metadata discovery of the Nonce Endpoint, PKCE, and the separate authorization-server metadata fetch). For the complete, normative sequence see the OpenID for Verifiable Credential Issuance 1.0 specification.
Protecting Authorization Codes With PKCE
Use Proof Key for Code Exchange (PKCE) to bind the issuer's authorization code to the wallet that started the request. The Issuer2 Service supports S256 and advertises it in authorization server metadata as code_challenge_methods_supported.
- Generate a fresh, cryptographically random
code_verifierfor each authorization request. Use 43–128 characters fromA–Z,a–z,0–9,-,.,_, and~, and keep it secret in the wallet. - Compute
code_challengeas the base64url encoding of the SHA-256 hash of the verifier's ASCII bytes, without padding. Sendcode_challengeandcode_challenge_method=S256to theauthorization_endpointadvertised in authorization server metadata. If using PAR, include them in the pushed request and use the returnedrequest_uriat authorization. - Send the original
code_verifierwhen exchanging the returned authorization code at the advertisedtoken_endpoint.
PKCE is optional by default (requirePkce is false, including on existing issuer resources where the field is absent). A supplied challenge always requires its matching verifier, including when enforcement is disabled. If the authorization request has no challenge, omit code_verifier during the code exchange; supplying one is rejected.
To require PKCE for an issuer, include this field alongside the other service settings when creating the service or updating its configuration:
{
"requirePkce": true
}
When required, an authorization or PAR request without a challenge returns invalid_request. Enabling the requirement also rejects outstanding codes issued without PKCE. An incorrect verifier returns invalid_grant; a PKCE rejection during code exchange consumes the code, so restart authorization instead of retrying that code.
Understanding issuer_state
issuer_state is how the Issuer2 Service correlates the authorization request it receives back at .../openid4vci/authorize with the issuance session created when the offer was made. Set "issuerStateMode": "INCLUDE" when creating the offer to include it.
AUTHORIZED offers omit issuer_state unless issuerStateMode is INCLUDE. Because per-offer overrides need this correlation, an AUTHORIZED offer that uses runtimeOverrides must set issuerStateMode to INCLUDE — see Runtime Overrides.
Related
- Setup — Configure
authProviderConfigurationfor the external IdP. - Create an Offer —
issuerStateModeand other offer parameters. - Create a Profile — ID Token Claims Mapping — Map ID token claims into credential fields.
- Pre-Authorized Code Flow — The simpler alternative, when user login isn't needed.
