Credentials in JSON

The credentials object is used to expose the information that the platform needs to collect from the integrator to be able to connect to their instance/account.

Information that is collected in this section typically includes:

  • The URL to the integrator’s instance (if there is not a shared cloud URL).

  • A username or other account identifier.

  • A password or other API key/token required to authenticate.

What do credentials represent?

Whenever an integrator uses your component on the platform, they will need to create a credentials object where they must provide values for each of the fields asked for in the credentials part of the component.

Once these values have been provided, they will be available to the component’s code in all actions, triggers, and related helper functions.

In addition to the fields identified in component.json, the platform will also prompt the integrator to assign a name to their credential. An integrator may have more than one credential for a given component if the integrator has multiple accounts or instances for the system the component is built for.

Omitting credentials

If the credentials object is not provided, then the integrator will not have the ability to select a credentials object between the Functions tab and the Input tab.

If the credentials object is provided and is {} or {"fields": {}}, then the integrator will have the ability to select a credentials object although there will be no inputs for the integrator to fill in apart from a credential name.

Credentials object structure

The credentials should be an object with the following properties:

Property name Description

fields

An object which describes the fields in the credential. See the article on fields for more information.

verifier

Java components only identify the Java class to be invoked by specifying the fully qualified name of a Java class that inherits the io.elastic.api.CredentialsVerifier class.

oauth1

specifies the details about OAuth v1.0 resources. Only used if an OAuthFieldView field is defined.

oauth2

Specifies the details about OAuth v2.0 resources. Only used if an OAuthFieldView field is defined.

Example

Below is an example credentials from the Magento 2 component.json file:

{
    "title": "Your Title",
    "description": "Your Description",
    "buildType": "Your BuildType",
    "credentials": {
        "fields": {
            "minorVersion": {
                "viewClass": "SelectView",
                "label": "Minor Version of Magento",
                "required": true,
                "placeholder": "Choose version of Magento",
                "model": {
                    "2": "v2.2",
                    "3": "v2.3"
                }
            },
            "edition": {
                "viewClass": "SelectView",
                "label": "Magento Edition",
                "required": true,
                "placeholder": "Choose environment",
                "model": {
                    "openSource": "Open source",
                    "enterprise": "Enterprise"
                }
            },
            "url": {
                "viewClass": "TextFieldView",
                "label": "URL",
                "required": true,
                "placeholder": "Instance URL"
            },
            "username": {
                "viewClass": "TextFieldView",
                "label": "Username",
                "required": false,
                "placeholder": "Paste username"
            },
            "password": {
                "viewClass": "PasswordFieldView",
                "label": "Password",
                "required": false,
                "placeholder": "Paste password"
            },
            "integrationToken": {
                "viewClass": "PasswordFieldView",
                "label": "Integration Token",
                "required": false,
                "placeholder": "Paste Integration Token"
            }
        }
    },
    "triggers": {
      "first_trigger": "First Trigger"
    },
    "actions": {
      "first_action": "First Action"
    }
}