Can't retrieve bearer token using Javascript | XM Community
Question

Can't retrieve bearer token using Javascript

  • 12 January 2021
  • 1 reply
  • 49 views

Hi,
I have a working request setup to retrieve an auth bearer token in Postman.
When I generate the code as I usually would to use in my app, I am getting the following error:
"localhost/1234 Access to XMLHttpRequest at 'https://iad1.qualtrics.com/oauth2/token' from origin 'http://localhost:1234' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Credentials' header in the response is '' which must be 'true' when the request's credentials mode is 'include'. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute."
I have also tried using fetch and am getting the same error.
I can retrieve the token using curl on the command line, so I am thinking the Qualtrics API doesn't support preflight requests?
Any assistance greatly appreciated as a bit time sensitive.
Thanks in advance!


1 reply

Update: as I'm working on an older stack, I have been able to retrieve the token using PHP/curl then pass it into react via props on the root component. It did not seem possible to fetch the bearer token using js.
I.e

Leave a Reply