Basic authentication to get a token

This system uses a two-step authentication flow. However, instead of sending credentials in the request body, the initial token request requires credentials via basic authentication in the Authorization header.

Configuration

This scenario requires a change to action.json in the endpoint configuration at /adapter-home-dir/entities/.system. No changes are required to the service instance configuration or the schemas.

action.json

Add an Authorization header to the getToken action. Because this header is defined directly in the headers object (not via auth_field), the adapter library will still substitute the {username} and {password} variables and apply base64 encoding when the token request is made.

1{
2 "name": "getToken",
3 "protocol": "REST",
4 "method": "POST",
5 "entitypath": "{base_path}/{version}/authentication/login",
6 "requestSchema": "tokenReqSchema.json",
7 "responseSchema": "tokenRespSchema.json",
8 "timeout": 0,
9 "sendEmpty": false,
10 "requestDatatype": "JSON",
11 "responseDatatype": "JSON",
12 "headers": {
13 "Authorization": "Basic {b64}{username}:{password}{/b64}"
14 },
15 "responseObjects": [
16 {
17 "type": "default",
18 "key": "",
19 "mockFile": "mockdatafiles/getToken-default.json"
20 }
21 ]
22}