Configuring custom functions in Connector Designer

When a user is creating a data source in Connector Designer, the user can select an authentication method from a list of predetermined options or dynamically added options. These dynamic options are provided by an administrator using Custom functions. Custom functions are used in situations where a static header cannot be set for a particular API call and a process is required to provide headers and their values at runtime.

The custom function is run before the API call is made, allowing the headers to be changed, removed, or added. After the headers are processed by the function, the API call continues with the resolved headers.

To provide Connector Designer with custom functions, use the configs/<config-name>/configuration/connector-designer/custom_functions/configuration.json to provide the name and location of the functions. For example:

{
    "<function-name>": {
        "functionFile": "<path-to-function-js-file>"
    }
}

Where:

  • <function-name> is the name of the function that is displayed as an authentication option to the user.

  • <path-to-function-js-file> is the path to the JavaScript (.js) file containing the function definition.

The structure of the JavaScript file that contains the function definition must have the following structure:

function buildCustomAuthorizationHeaders (headers) {
  // Your implementation to return the headers
  return headers; // The returned headers that are used in the API call
};

module.exports = buildCustomAuthorizationHeaders;

To update Connector Designer with your changes, run:

./scripts/deploy