Default Localization Behaviour - AS Admin API
This chapter explains how the default language behaviour works concerning translations in the Authorization Server Admin API.
When deploying an Authorization Server, the 'authorizationApi.application.config' section of the deployment YAML file must be configured to define a default language (i18n.defaultLang
) as well as values for all accepted languages (i18n.allLanguages
). This default language is automatically applied to any element (e.g. Client, Wallet, Resource Definition etc.) that is being created using the Authorization Server Admin API even if the Accept-Language
header is not explicitly passed during the first POST request that is made to create the element (refer to Authorization Server Localization for details).
The following steps detail how the available translations and applied default language can be reviewed by making a series of API calls.
1. Creating an element without the 'Accept-Language' header
This sample command demonstrates the creation of any element (Resource Definition in this case) without the Accept-Language
header. A new Resource Definition by the name of 'My-new-definition' is created by passing the following POST request:
curl --location --request POST 'http://localhost:8082/registry/resource-definitions/'
--header 'Content-Type: application/json'
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiIxZGQ4ZTUxNC03YWZkLTRlMWMtYWJlNC1hNjczN2ZjNjk4OTYiLCJzdWIiOiJhMjIxNTE4ZS1kYjY2LTRmOWYtYjU0My1hMTUyNDc3N2UwODQiLCJpc3MiOiJsb2NhbGhvc3QiLCJhdWQiOiJsb2NhbGhvc3QiLCJleHAiOjE2NDYxNzgzNjd9.wF5sxx_UsDhldWWKM4Ja_mbYmK_iBo-pCpFQQsi8LJA' --data-raw '{
"name": "My-new-definition",
"type": "https://new-definition-general.com",
"resource_scopes": ["read"],
"description": "My new definition",
"icon_uri":"https://some-icon-uri"
}'
Sample Response:
{
"resource_def_id": "ff591f22-64ba-4892-adc9-d1fd419bc87a",
"name": "RES_DEF-NAME-e9f8231b-259e-469f-91e5-91a0f49862e8-1646172426686",
"icon_uri": "RES_DEF-ICON_URI-5e32f70d-22df-43ed-9d22-0c96a472536d-1646172426970",
"description": "RES_DEF-DESC-e48cc33d-fab0-47d3-ade6-55d479257e8a-1646172426957",
"max_permission_duration": 18000000,
"resource_scopes": [
"read"
],
"type": "https://new-definition-general.com"
}
The response returns resource keys for all fields that can be localized. In this example, when creating a new Resource Definition, this includes the name
, icon_uri
and description
fields.
2. Retrieving Available Translations
Next, make a GET request to retrieve all translations for the name
field of the newly created Resource Definition using the appropriate resource key returned in the response above ("RES_DEF-NAME-e9f8231b-259e-469f-91e5-91a0f49862e8-1646172426686"). This key corresponds to the name
field.
curl --location --request GET 'http://localhost:8082/localization/translations?key=RES_DEF-NAME-e9f8231b-259e-469f-91e5-91a0f49862e8-1646172426686'
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiIxZGQ4ZTUxNC03YWZkLTRlMWMtYWJlNC1hNjczN2ZjNjk4OTYiLCJzdWIiOiJhMjIxNTE4ZS1kYjY2LTRmOWYtYjU0My1hMTUyNDc3N2UwODQiLCJpc3MiOiJsb2NhbGhvc3QiLCJhdWQiOiJsb2NhbGhvc3QiLCJleHAiOjE2NDYxNzgzNjd9.wF5sxx_UsDhldWWKM4Ja_mbYmK_iBo-pCpFQQsi8LJA'
Response:
{
"language_translations": [
{
"key": "RES_DEF-NAME-e9f8231b-259e-469f-91e5-91a0f49862e8-1646172426686",
"translations": {
"en": "",
"fr": "My-new-definition",
"es": ""
}
}
]
}
In the language_translations response above, the name 'My-new-definition' appears against the French field. This indicates that in the HELM Chart YAML configuration, the default language in 'authorizationApi.application.config' section is set to French. A sample of such a configuration is as follows:
i18n:
defaultLang: fr
allLanguages: en, fr, es
For more details on configuring default and available languages for the Authorization Server Admin API, refer to Localization Settings.