Developer Discussions

Ask a Question
Back to All

I am having trouble authenticating with maya checkout. Help me.

(edited)

I got this public key "pk-redacted" from the provided sandbox API keys.

I converted the string "pk-redacted:" to base64 using btoa and the result is : "redacted"

My code looks like this.

key = "pk-redacted"

function convertToBase64(key) {
console.log(key + ':');
return btoa(key + ':');
}

const instance = axios.create({
headers: {
Authorization: 'Basic ' + convertToBase64(key),
},
});

instance
.get(url)
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error);
});