It is possible to use Hypermedia Authentication API to create an API driven user interface, such as a Single Page Application (SPA). The steps to accomplish this via the template system are described in the following paragraphs.
Enable API driven on the selected authentication profiles by adding the api-driven-ui configuration parameter in the corresponding authentication-service settings.
api-driven-ui
Assign the use_api_driven_ui template setting to true. This is done by adding #set ($use_api_driven_ui = true) to a settings.vm file:
use_api_driven_ui
true
#set ($use_api_driven_ui = true)
settings.vm
overrides
Create a index.vm velocity template with the HTML document to load the API-driven application. This file should be present inside a api-driven-ui folder, located on the overrides folder or on a template area. The $_apiDrivenClientInfo velocity context object contains the information required to configure HAAPI Web SDK, namely:
index.vm
$_apiDrivenClientInfo
$_apiDrivenClientInfo.clientId
$_apiDrivenClientInfo.tokenEndpoint
const fetchConfig = { clientId: '$_apiDrivenClientInfo.clientId', tokenEndpoint: '$_apiDrivenClientInfo.tokenEndpoint', } const apiFetch = HaapiDriver.createHaapiFetch(fetchConfig)
The API-driven application will be loaded on the first interactive step of the authentication flow, which can be the authenticator selector or a specific authenticator user interface.