#
Authorization code grant flow without proof key for code exchange
#
Introduction
While the traditional authorization code flow remains a valid method for web applications, it is highly recommended to adopt Proof Key for Code Exchange (PKCE). By using PKCE, you ensure a more robust and secure implementation of the OAuth 2.0 protocol.
But the OAuth 2.0 specification allows to obtain a token pair via authorization code flow even without PKCE as well. If the external system/application is unable to enhance to support PKCE, then this method can be used.
It consists of the following steps:
#
Step 1: Authorizing the user
The URL of the Pagero Login page is:
Request method: GET
Required query parameters:
Optional query parameters:
#
Example
#
Step 2: Obtaining authorization code
Upon successful login, the authorization_code
is posted back as a query parameter to the url defined in the redirect_uri
query parameter.
Response Structure:
#
Example
- https://urltoclient:4443/?code=0F7ijeaW4BCwhvyg6ozY9PeLsFF6KUi1&state=exampleState&iss=https%3A%2F%2Fauthorization-server.com
#
Step 3: Exchanging to a token
Using the authorization_code
, it’s now possible to obtain an access_token
and a refresh_token
.
The URL for doing so is:
Request method: POST
Required parameters in application/x-www-form-urlencoded
:
Required headers (if not client_id
and client_secret
provided in the body):
Response Structure:
#
Example with header option
curl https://sso.pageroonline.com/oauth/v2/oauth-token \
-d grant_type=authorization_code \
-d code=0F7ijeaW4BCwhvyg6ozY9PeLsFF6KUi1 \
-d redirect_uri=https://urltoclient:4443 \
--user 'client-id:client-secret'
The response will contain a JSON body that looks like this (when scope
is set to all
):
{
"token_type": "bearer",
"access_token": "_0XBPWQQ_2a66dd33-e108-4dc3-b653-e71b9feae02e",
"refresh_token": "_1XBPWQQ_e61b091b-9139-4268-a7c7-765d2d418d52",
"scope": "",
"claims": "publicid",
"expires_in": 600
}
#
Making an API request using an access token
When making an API request, the access token should be provided in an Authentication header as a bearer token.
curl https://api.pageroonline.com/someresource \
-H 'Authorization: Bearer _0XBPWQQ_2a66dd33-e108-4dc3-b653-e71b9feae02e'