API Keys are generated for your account specifically and they also have an expire date
To use an API Key to communicate with the API you can do something like this:
async function req(url, api_key = null, method = "GET", data = {}) {
const baseURL = "https://api.maskon.no";
const response = await fetch(baseURL + url, {
method: method,
credentials: "same-origin",
headers: {
"Content-Type": "application/vnd.api+json",
"Authorization": "ApiKey " + api_key
},
body: method == "POST" ? JSON.stringify(data) : null
});
return response.json();
}
Notice that unlike the example for Bearer tokens we use ApiKey as the prefix for our Authorization header