Presentation exercises
OID4VP Presentation exercises and explanation
Prerequisites
In the below exercises we will be creating credential offers in different ways. Please read the OID4VP introduction page first that explains the concept of credential offers.
Authorization request and session initiation
In the below exercises you will learn how to present credentials using an Authorization Request by value
and by reference
. You will actually present using a mobile wallet!
Exercise 1: Credential offer by value, using pre-authorized_code
Please use the create-authorization-request
API (docs) or
API (swaggerhub) to create a so-called Authentication Request by providing a presentation definition
.
You will need to provide a definitionId
for instance with value PensionSdJwt
as path parameter, given every OID4VP Authorization Request will internally use a Presentation Definition (or DCQL query in the future)
The expected outcome should be an HTTP response with something like:
The above authRequestURI is the actual URI value that can be used in a link or QR code (more on that later). A wallet is using that value to start the presentation process with the Relying Party. This value is always by reference.
The authStatusURI is the URI you need to use to track the status progress over time (next exercise). You will use the correlationId in that process to get the correct session.
Exercise 2: Create a QR code from the URI and scan it with a mobile wallet
In a lot of situations your wallet is on a mobile device, while you might be visiting the relying party website using another device like a tablet or desktop computer. This is the so called cross-device flow. AAlthough new mechanisms are being developer whereby your mobile wallet can register with your browser, right now an Authorization Request is being conveyed using a QR code. This is a short exercise to show that all you really need to do is display the request value in a QR code to really start the interaction with the relying party from a mobile device.
Take the outcome of Exercise 1 and copy the value of the authRequestURI
field from the JSON response. So do not copy the whole JSON response. You should only copy the value that starts with openid-vc://?request_uri=....
also minus the quotes in front and at the end.
Go to an online QR code generator like: https://www.qr-code-generator.com/ and past the request value. You should get a QR code back. Below is an example QR code. Obviously yours will differ.
Now take you mobile wallet application and make sure you are logged in. Typically the wallet app will have a QR code scanning functionality. You can use that to initiate the presentation process. Most wallets will also register with the Operating System, meaning you can also scan the QR code using your regular photo/camera app instead. Then depending on your brand the wallet will open, or you will get a choice which wallet app to open. Finish the presentation process on your mobile wallet, to see that all it took was creating a URI and displaying that as a QR code.
Exercise 3: Protect the QR code with a transaction code?
In the Issuer exercises we protected the QR code with a transaction/pin code. This is not possible in the OID4VP flow. Could you write down why that is? What are the big differences between the 2 flows and why was the pincode needed?
Session status
Up until now we only have been using one endpoint to start the presentation process from the API and then we received the request to present credentials in our wallet. Typically you will have a portal or web-app that is guiding the user. This is the case both in the same-device as cross-device flow. When you create a web frontend for the presentation process, you will want your frontend to react to states changes in the presentation process, to inform the user about errors, success etc.
Not only that, the goal is to eventually receive one or more presentations containing the credentials from the wallet holder.
The create-authrozation-request
endpoint we used above internally creates a session. The session contains all kind of information needed by the relying party; one of the important properties it has in the session is the state
. The state can have the following values:
state | Description |
---|---|
created | A Authorization Request is created. This is the initial state |
sent | When the wallet has retrieved the Authorization Request by reference using the URI provided in the link |
recieved | When the Relying Party received the presentation(s) from the wallet |
verified | When the Relying Party has verified that the presentation(s) were cryptographicaly correct and were satisfying the credential queries (Presentation Exchange, DCQL) |
error | An error occured |
Exercise 4: Get the initial status
In this exercise we will retrieve the initial status of the credential offer. Without a wallet involved. The state will be created
Please use the get-authorization-status
API (docs) or
API (swaggerhub) to check the progress of the session using the correlationId
value you supplied during session creation above and definitionId
with the value you previously used in the path. You could also create a new session as explained in the above exercises.
You should get a response like this:
The status
is from the table above.
Exercise 5: Now scan the QR code
In this exercise we will continue where the previous exercise ended. We will use the wallet to scan the QR code. Make sure that you create the QR code from the authRequestUri
Scan the QR code with the mobile wallet. Once the wallet is in the present screen, send in the credential
Please use the get-authorization-status
API (docs) or
API (swaggerhub) to check the progress of the session using the correlationId
value you supplied during session creation above and definitionId
with the value you previously used in the path. You could also create a new session as explained in the above exercises.
You should get a response like this:
The status
is from the table above.
Note that the response all of a sudden contains the information that was submitted by the wallet