我正在尝试使用基本身份验证发出dojo xhrGet请求,但我一直收到403禁止错误。我可以从命令行使用curl发出请求,所以我知道我的凭据是有效的。当我检查请求标头时,甚至没有设置Authorization:Basic标头。我做错了什么:
var lookupArgs = {
url: "https://myendpoint.com/myapi/endpoint",
user:"myemail@myendpoint.com",
password:"mypassword",
handleAs: "text",
load: function(data) {
content_node.innerHTML = data;
},
error: function(error) {
content_node.innerHTML = error;
}
}
dojo.xhrGet(lookupArgs);
请求标题:
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