tableau / webdataconnector

Bring the data you care about into Tableau
https://tableau.github.io/webdataconnector
MIT License
678 stars 585 forks source link

CORS policy not being bypassed #525

Open bmp02050 opened 1 year ago

bmp02050 commented 1 year ago

I am trying to write an connector that requires a user to send in a ClientID and Secret through OAuth2 as client_credentials in order to get an access token. I can successfully use the "post" connector method to retrieve the data, however, when I go to create a request to our API, I get 405 errors and CORS exceptions, even though I am passing the request options to bypass CORS policy.

return new Promise(function (resolve, reject) { let requestOptions = { bypassCorsPolicy: true, headers: { 'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json' } }; let endpoint = "API Path"; let requestBody = {};

    post(endpoint, requestBody, requestOptions)
        .then(data => {
            console.log('Get Groups successful!');
            console.log(data); // Process the response data
        })
        .catch(error => {
            console.error('Error:', error);
        });
});