API Key Based Authentication

To support invoking of REST APIs secured with an API key, use the API Key Based Authentication managed security policy.

Overview

To add the API Key Based Authentication policy to your document, use the available authentication scheme template. See Implement a New Connection Definition.

You can customize the security policy as needed for a connection definition.

Security Properties

A connection definition that uses this security policy defines the following properties in the securityProperties section. See Connection Properties and Sample Code.

The values in the name, displayName, shortDescription, and description columns list the default values that appear when you insert a security policy into an adapter definition document. You can update these values if needed.

name displayName shortDescription description Data type Required

accessToken

API Key

Generated API key.

Generated API Key used to identify the client that is making the request.

Password

Yes

accessTokenUsage

API Key Usage

Default: -H Authorization: Bearer ${api-key}

URI syntax to show how the API key is passed to access a protected resource.

To pass the API key as a query parameter, specify the following value as a query parameter: "?<query-param-name>=${api-key}"

To pass the API key as a header, specify the following value: "-H Authorization: Bearer ${api-key}"

Text

No

Sample Code: API Key Based Authentication

The following code sample shows how to define the security policy in a connection using API key based authentication.

"securityPolicies": [
   {
     "type": "managed",
     "policy": "API_KEY_AUTHENTICATION",
     "description": "API Key Based Authentication",
     "displayName": "API Key Based Authentication",
     "scope": "ACTION",
     "securityProperties": [
       {
         "name": "accessToken",
         "displayName": "API Key",
         "description": "Provide the API Key",
         "shortDescription": "Example: <The generated api key>",
         "hidden": false,
         "required": true
       },
       {
         "name": "accessTokenUsage",
         "hidden": true,
         "required": true,
         "default": "-H Authorization: Bearer ${api-key}"
       }
     ]
   }
]