我正在尝试连接到具有必须通过主体传递且具有基本身份验证的凭据的api。我无法连接到它,并且使用ajax给了我403错误。这些是连接说明:
1-他们必须进行身份验证的端点:
https://ngapi.freedompop.mx/api/auth/token/credentials/xx
正如我之前提到的,有必要使用具有以下凭据的基本身份验证:
用户名:4148974密码:GmiA2sspqT23RerXUts3xd4cCClnm6cl
除了正文部分之外,还必须发送以下参数:
用户名:xxx密码:jvgXvHBrTrxkKJStxx
这是我的代码:
type: "POST",url: "https://ngapi.freedompop.mx/api/auth/token/credentials",dataType: 'json',async: false,headers: {
"Authorization": "Basic " + ("4148974" + ":" + "GmiA2sspqT23RerXUts3xd4cCClnm6cl")
},data: {"username": "xxx","password": "jvgXvHBrTrxkKJSt"},success: function (response){
alert('Thanks for your comment!');
var tokenct = response.acces_token;
},function(error){
console.log(error);
}
});
});