Dweid
5 years agoNew Member
API BASIC Authentication Help
I keep getting an authentication error (401) any one see any issues with my code?
var customerID = 'xxxx'; var clientSecret = 'yyyyy'; var encodedData = btoa(customerID + ':' + clientSecret); var authorizationHeaderString = 'Authorization: Basic ' + encodedData; var myHeaders = new Headers(); myHeaders.append("Access-Control-Allow-Origin","https://secure.logmein.com") myHeaders.append("Access-Control-Request-Headers", "https://airtables.com") myHeaders.append("Authorization" , authorizationHeaderString) var formdata = new FormData(); formdata.append("groups", ""); var requestOptions = { method: 'GET', mode: 'no-cors', headers: myHeaders, redirect: 'follow', }; fetch("https://secure.logmein.com/public-api/v2/hosts", requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error));