The GoTo Community is currently experiencing some technical issues affecting new posts and comments. We are actively working with our service provider and apologize for the frustration.

Forum Discussion

Dweid's avatar
Dweid
New Member
6 years ago

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));
No RepliesBe the first to reply