1. Home
  2. Docs
  3. Custom API
  4. Headers and Authorization

Headers and Authorization

Request headers are important fields if your datasource’s API endpoint needs them for additional information. If you are making authorized request to fetch data for your own account, then you may need them.

How to add headers to Custom API?

 

customapi_method_post_headers

To add headers, you can follow the steps below: 

  • Click on the “+” icon.
  • Once the header row is opened, you can enter the Header Key and its Value.
  • You can even delete the header row by clickin the “x” icon at the right of the row.

NOTE: If there is any header row where the Key and the Value field is blank, the error will shown. So make sure there are no blank values.

 

What authorization methods are available in the Custom API?

Currently, the availale authorization are

  • Basic
  • Bearer

If you are looking for any other authorization, feel free to mail us at our contact info with the use case.

You can even use the authorization header to authorize the request if the datasource’s REST documentation describes other method.

Authorization: Basic

Once you select the “Basic” authorization dropdown, you’ll be asked to enter the username and password field.

Once you enter these fields, the header row will be generated automatically with the key as “Authorization” and value as based64 encoded “username:password” .

customapi_method_get_auth_basic

 

NOTE: While some APIs use other encoding for usuername and password, if that is the case, then you can simply set authorization to none and manally imput the header as Key -> “Authorization” Value-> Encoded value. 

 

Authorization: Bearer

You can select the bearer authorization form the dropdown, once selected you’ll be asked to enter the token information in the box.

Once you enter the token, the header row fields will be generated as “Authorization” and value as “Bearer {{Token}}”. {{Token}} is the same as what you have entered in the token box. 

customapi_method_get_auth_bearer

 

NOTE: If you manually input the “Authorization” header & select the authorization dropdown as Basic or Bearer. The Basic  or Bearer values will be used to regenerate the “Authorization” header, so make sure to select authorization dropdown as none.

 

How to use variables in the authorization?

If you are going to save and run the queries in the sheet, it is highly recommended that you use the environment variables.

You can simply create a variable for your access token as {{token}} and use it in token field.

For more information, you can check the variables documentation.

 

Leave a Reply

Your email address will not be published. Required fields are marked *