Configuring REST API connectors -Basic Auth

When building your applications you would often be making use of a variety of services like Trello, Twilio, SendGrid and so on that provide APIs to use their functionality. An important concern is to have ways and means to keep the systems secure. Authentication is an extremely crucial part of your API design. There are different methods of API authentication, using the API Key, using basic Auth which is using the username and password, and using the OAuth which is a standard for accessing user permissions without a password.

One of the ways to configure is to use the Basic Auth. This is mainly used in scenarios where the API relies on HTTP Basic authentication standard. When you are setting up a new service, DronaHQ prompts for the username and password and then adds the appropriate encoded authorization headers to the API request.

You can have a quick look at this video here to understand how to configure the Basic Auth.

Configuring the third party API connector

To add third party connectors, under Studio > Connectors, click (+) Connector.

Studio has different options including the use of the REST API that allows you to easily connect to the Third Party API access to important systems. We will be selecting the REST API for this example.

To configure an API you typically need to configure an API Category, Manage an Account and then add the API.

Configure API Category

You first need to provide the details of your API Category, thus enter a Category name and Category description. Add an appropriate icon and click Continue.

Let us take an example here to add the Freshdesk API.

Now select the type of Authentication that you want to use. Here we are going to use the Basic authentication. So select Basic Auth and click Continue.

Provide Authentication details

Now you need to provide the configuration parameter required by the specific API. The details are available in the documentation provided by respective 3rd party services. Thus depending upon fields required for each item like subdomain or team name you would define the parameter which would then have to be provided by the User.

The two main parameters that can be used for authentication are the username and password. In case you want to make any updates to the username and password you can edit the Password parameter settings like the user-friendly labels, help text, placeholder values, and so on. The Default value field can be hardcoded to X (as required in this example for the Freshdesk API) and you can also keep it hidden from the user. By assigning a default value it will be used instead of missing or null values every time the service runs. If other details like the subdomain or team name, API Key are required for authentication in addition to username and password, you just need to add them using Add field.

You need to add the appropriate field based on the service that you are configuring. In this example, we are going to consider here the Freshdesk API. It needs an additional field API Key as a parameter. We will add that field as shown below:

You can then add the Label which is a user-friendly name for the users, field Key(which can be made a mandatory field). Then add the type of field as Use String or Password. By default, it would be Use String. However, if you want the values to be secret or masked, then change the type as Password. Then select the Target parameter is to be placed namely Header, as Querystring Parameter, as Property inside Body or None. In case you set None then you need to specifically add this key in your API request using {{key_name}}.

In the above example, the API Key is required to be passed to the username field. So we will give the key name of the API Key field. So Edit the username field and change its Default value to {{api_key}}. You can hide it as you dont require any input for the username and password. In this example, we have seen that the Freshdesk needs password to be hardcoded. So we are hardcoding it as ‘X’.

There could be other parameters that could be required which should be verified from the documentation of the respective third party services. In the above example, we have added the subdomain as a parameter. This will be a dynamic parameter which you can also check when running a Test request.

Once the configuration settings are done you need to configure a Test request. A simple API endpoint that would allow you to check the user credentials is to be added. The data from input forms is added by default. You can see in the example below the parameter subdomain has been added in the method. Now whenever this API is called the subdomain would be replaced.

When you test the authentication scheme you would find that it asks for the Subdomain name in this example here. Enter the name and click Submit.

enter api key

This way you would be adding the necessary parameter and testing the configuration.

Under Response you would see the success code or the response values from your respective API.
When the request is successful it will show the respective message. Click Continue and the process is complete.

Your API can be seen under Custom API Connectors now. You can now see the API under Connectors > + Connector and view the parameters available.

Add account to the API configuration

The next thing is to add an account to connector configuration. Click Manage Accounts > Add Account and then the Account name, and the necessary parameters, which in this case are API Key and Subdomain.

Your account can be seen in the list of accounts. Add the accounts as required.

Make sure that you provide an account name and use the same steps used earlier when testing configuration to check details.

Add API to configure

Now that you have configured the API category and added accounts you now need to add the API for configuration. Under Studio > Connectors > Custom API Connectors you can see your connector is added. To add this API, click Add API.

Now Add the Service Name, the Method and the URL. In this case you are choosing a GET method as shown below:

Under configuration, there are Request, Response, and Query String configurations. Add the Authentication details and select Account. When you add the URL in the above example with the subdomain as the parameter, it would get added to the PATHPARAMS.

Once you have configured the API as required, you can click Test and Save. You can check the response accordingly to your request. The API is now added successfully to your Custom API connectors.

These API can be used in your Apps and workflows using the CALLAPI function. You can refer to this link here to understand how to use the API services.