Basic Authentication Header Generator

The form below encodes credentials to base 64. Enter your user ID and password, 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.

 

Contents

What is Basic Authentication?

Basic Authentication is a common method of authenticating to an API. With Basic Authentication, you send a request header as follows:

  • Key = 'Authorization'
  • Value = 'Basic '+ base 64 encoding of a user ID and password separated by a colon
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.

How to Use Basic Auth Credentials?

Most API clients, as well as command line options like Curl, have a Basic Auth input option that will encode credentials for you.

However, if your tool doesn't have this option, or you'd prefer not to directly enter your username and password, Basic Auth credentials can be entered into the Headers section of any no-code API client like this:

basicauth-apiconnector
screenshot from API Connector for Sheets

Alternative Encoding Methods

#1 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:

basic-access-img1

Copy this value (without the quotation marks)

#2 Curl Import Tools

Curl is an open-source, command line tool for sending data. Many API clients include an option to import Curl code snippets, e.g:

These Curl import tools will automatically encode your credentials to base64 during the import process.

#3 Automatic URL-based encoding

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

https://yourname:[email protected]/admin/api/2024-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. (In API Connector, if you enter a basic access Authorization header while also using automatic basic authentication, the Authorization header will take precedence).