我想在Jquery中使用基本身份驗證協議來驗證用戶,但它一直給出錯誤:「XMLHttpRequest無法加載https://api.credly.com/v1.1/authenticate。請求標頭字段授權不被Access-控制允許頭「。基本身份驗證不工作在jquery,但在其他語言工作
但是,當我使用郵遞員客戶端檢查API時,它工作正常。
jQuery代碼:
var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.credly.com/v1.1/authenticate",
"method": "POST",
"headers": {
"x-api-key": "myAPIkey",
"x-api-secret": "mySECRET",
"authorization": "Basic "+btoa(<email> + ":" + <password>)
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
的API正在爲郵差客戶,所以應該在沒有任何問題,但它不是在jQuery的工作。 請幫忙。
可能重複的[ '是不允許的請求頭字段授權' 的錯誤 - Tastypie](http://stackoverflow.com/questions/10548883/request- header-field-authorization-is-not-allowed-error-tastypie) – D4V1D