Search API Connector Documentation


Basic Authentication

While there are many possible ways to authenticate to an API, the most common methods include OAuth2, API keys, and Basic Authentication (the focus of this article).

With Basic Authentication, you send a request header as follows:

  • Key = ‘Authorization’
  • Value = ‘Basic ‘+ base 64 encoding of a user ID and password
Some platforms may require you to encode slightly different details, e.g. an API key instead of a user name, or a plus sign (+) instead of a colon in the middle. The platform documentation should contain the exact details of what needs to be encoded.

The below article provides several methods for encoding credentials, as well as instructions on how to enter them into the API Connector add-on for Google Sheets.


Part 1: Methods to Encode Credentials

Encoding Form

To encode your credentials, type your username and password into this form, using the format username:password. Your encoded credentials will appear underneath.

The encoding script runs in your browser, and none of your credentials are seen or stored by this site.




Chrome Developer Tools

You can encode your credentials yourself by opening Developer Tools in your browser (F12 on Windows/Linux or option + ⌘ + J on OSX). In the console, type in the following and click enter:
encodedData = "Basic " + window.btoa('YOUR_USERNAME:YOUR_PASSWORD')

You’ll need to substitute in your own user credentials for YOUR_USERNAME and YOUR_PASSWORD, like this:


Copy this value (without the quotation marks)

Header Generator Tool

Here’s a header generator tool:

cURL Import Tool

When using API Connector’s cURL import tool, any imported cURL requests will automatically encode your credentials.

Automatic URL-based encoding

API Connector (and most other API clients) will automatically apply basic authentication if you enter your credentials as https://username:[email protected]. For example, this URL would automatically encode your credentials in a call to Shopify:

https://yourname:[email protected]/admin/api/2022-01/shop.json

When you enable automatic basic authentication, you do not need to encode your credentials manually and shouldn’t enter an Authorization header key/value pair. (If you enter a basic access Authorization header while also using automatic basic authentication, the Authorization header will take precedence).

Part 2: Use Encoded Credentials

To use Basic Authentication, enter a Header where the Key is Authorization, and the value is Basic YOUR_BASE64_ENCODED_STRING, like this:


It should look like this:

If you are using the cURL import tool or URL-based encoding, you don’t need to manually enter this header.

Previous Add Request Body
Next Connect to an OAuth API

1 thought on “Basic Authentication”

Leave a Comment

Table of Contents