API Reference

Basic Authentication

The authentication method used for this API

Explanation

Basic Authentication is a method for an HTTP user agent to provide a username and password when making a request. The username and password is combined with a colon in between, and the string is then encoded using base64 encoding. This resulting encoded string is then provided in subsequent HTTP request within the Authorization header. An example of this is provided below.

Example

Suppose that the username and password for a given user is: valmarman2024 and whoopie!23.

These two values would be combined together with a colon in between, such as: valmarman2024:whoopie!23.

This string is then encoded using standard base64 encoding.
The result of this would be: dmFsbWFybWFuMjAyNDp3aG9vcGllITIz.

This value is then used in the Authorization header of the HTTP request proceeded with Basic.

Code

const credentials = "valmarman2024" + ":" + "whoopie!23";
const encodedValue = btoa(usernameAndPassword); // = dmFsbWFybWFuMjAyNDp3aG9vcGllITIz

fetch('https://gateway.valmarmerchants.com/api/...", {
  method: "POST",
  headers: {
    "Authorization": "Basic " + encodedValue,
    "Content-Type": "application/json"
  }
  body: JSON.stringify(bodyData);
})