Basic Authentication to Get Token
  • 15 Nov 2022
  • Dark
    Light
  • PDF

Basic Authentication to Get Token

  • Dark
    Light
  • PDF

Article summary

Scenario

This system has a two-step authentication, but instead of using a normal body to request a token, the adapter needs to use basic authentication to get the token.

This requires the following changes to be made to the endpoint configuration for the adapter in the /adapter-home-dir/entities/.system directory.

Changes to the action.json File:

  • To begin, you need to add a header to the token request. The header is added into the headers section. The header we want to send on the request is the Authorization header. Notice that in this case, since it is already defined as a header, we do not need to use header.headers.xxx). Instead, we just need to provide the name of the header. The value of the header is the format of Basic Authentication. Since this header is on the token request, the adapter library will still replace the variables and encode it (this is not normally done on header data).

action.json Example

{
  "name": "getToken",
  "protocol": "REST",
  "method": "POST",
  "entitypath": "{base_path}/{version}/authentication/login",
  "requestSchema": "tokenReqSchema.json",
  "responseSchema": "tokenRespSchema.json",
  "timeout": 0,
  "sendEmpty": false,
  "requestDatatype": "JSON",
  "responseDatatype": "JSON",
  "headers": {
    "Authorization": "Basic {b64}{username}:{password}{/b64}"
  },
  "responseObjects": [
    {
      "type": "default",
      "key": "",
      "mockFile": "mockdatafiles/getToken-default.json"
    }
  ]
},

Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.