How do I make a request using dojo.xhrGet() with Basic Authentication?

341 views Asked by At

I'm trying to make a dojo xhrGet request using basic authentication but I keep getting 403 forbidden error. I can make the request with curl from the command line, so I know my credentials are valid. When I check the request headers, the Authorization: Basic header isn't even being set. What am I doing wrong:

    var lookupArgs = {
     url: "https://myendpoint.com/myapi/endpoint",
     user:"[email protected]",
     password:"mypassword",
     handleAs: "text",
     load: function(data) {
         content_node.innerHTML = data;
     },
     error: function(error) {
         content_node.innerHTML = error;
     }
 }
dojo.xhrGet(lookupArgs);

Request Header:

GET /myapi/endpoint HTTP/1.1
Host: myendpoint.com
Connection: keep-alive
Origin: http://my-origin
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3315.3 Safari/537.36
Content-Type: application/x-www-form-urlencoded
Accept: */*
Referer: http://my-origin
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
0

There are 0 answers