Skip to content

Commit ce9d3a3

Browse files
Merge pull request #5697 from wso2/fixing-product-is-issue-26020-1762527948
Fix: Add front channel grant flow details to RAR documentation for all affected versions (Product IS issue #26020)
2 parents 6224072 + 4056bc5 commit ce9d3a3

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

en/includes/guides/authorization/rich-authorization-requests.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,75 @@ access token with the requested authorization details.
323323

324324
The client application can now retrieve the user's payment information from the resource server by including the obtained access token in the request.
325325

326+
### Sample authorization code grant flow
327+
328+
The authorization code grant is a front channel grant that requires user interaction and consent (configurable from the Application's **Advanced** section in Console). This section describes how to use rich authorization requests with the authorization code flow.
329+
330+
#### Step 1: Initiate authorization request
331+
332+
The client initiates an authorization request to the authorization endpoint with the `authorization_details` parameter. The request includes the url-encoded `payment_initiation` authorization details type.
333+
334+
=== "Sample request (/authorize)"
335+
336+
```bash
337+
https://localhost:9443/oauth2/authorize?response_type=code&client_id=<clientID>&redirect_uri=<redirectURI>&scope=openid&authorization_details=%5B%7B%22type%22%3A%22payment_initiation%22%2C%22actions%22%3A%5B%22initiate%22%5D%2C%22locations%22%3A%5B%22https%3A%2F%2Fexample.com%2Fpayments1%22%5D%2C%22instructedAmount%22%3A%7B%22currency%22%3A%22USD%22%2C%22amount%22%3A%223000.00%22%7D%2C%22creditorName%22%3A%22Merchant%20A%22%2C%22creditorAccount%22%3A%7B%22iban%22%3A%22%22%7D%7D%5D
338+
```
339+
340+
The user authenticates and provides consent for the requested authorization details. After consent, the authorization server redirects to the specified redirect URI with an authorization code.
341+
342+
=== "Sample response (/authorize)"
343+
344+
```bash
345+
<redirectURI>?code=<authorizationCode>&session_state=<sessionState>
346+
```
347+
348+
#### Step 2: Exchange authorization code for access token
349+
350+
The client exchanges the authorization code for an access token by sending a request to the token endpoint.
351+
352+
=== "Sample request (/token)"
353+
354+
```bash
355+
curl --location 'https://localhost:9443/oauth2/token' \
356+
--header 'Content-Type: application/x-www-form-urlencoded' \
357+
--header 'Authorization: Basic <base64EncodedClientCredentials>' \
358+
--data-urlencode 'grant_type=authorization_code' \
359+
--data-urlencode 'code=<authorizationCode>' \
360+
--data-urlencode 'redirect_uri=<redirectURI>'
361+
```
362+
363+
=== "Sample response (/token)"
364+
365+
```json
366+
{
367+
"access_token": "a1b2c3d4-e5f6-7890-g1h2-i3j4k5l6m7n8",
368+
"refresh_token": "z9y8x7w6-v5u4-t3s2-r1q0-p9o8n7m6l5k4",
369+
"authorization_details": [
370+
{
371+
"locations": [
372+
"https://example.com/payments1"
373+
],
374+
"instructedAmount": {
375+
"currency": "USD",
376+
"amount": "3000.00"
377+
},
378+
"type": "payment_initiation",
379+
"creditorName": "Merchant A",
380+
"actions": [
381+
"initiate"
382+
],
383+
"creditorAccount": {
384+
"iban": "c6142dc9-588c-49ec-8341-1b157c441d02"
385+
}
386+
}
387+
],
388+
"token_type": "Bearer",
389+
"expires_in": 3600
390+
}
391+
```
392+
393+
The client application can now retrieve the user's payment information from the resource server by including the obtained access token in the request.
394+
326395
### Validate the access token
327396

328397
To verify if an access token is valid and check its associated authorization details, invoke the token introspection endpoint.

0 commit comments

Comments
 (0)