Ajax 使用jquery/axios获取OAuth2访问令牌
我想获得一个新的访问令牌,在postman中效果很好,但当我尝试在代码中这样做时,我的chrome控制台中不断出现错误 使用ajax:Ajax 使用jquery/axios获取OAuth2访问令牌,ajax,oauth-2.0,axios,postman,access-token,Ajax,Oauth 2.0,Axios,Postman,Access Token,我想获得一个新的访问令牌,在postman中效果很好,但当我尝试在代码中这样做时,我的chrome控制台中不断出现错误 使用ajax: POST https://10.250.252.1:43002/oauth/token net::ERR_CERT_AUTHORITY_INVALID jquery-3.3.1.min.js:2 使用axios: POST https://10.250.252.1:43002/oauth/token net::ERR_CERT_AUTHORI
POST https://10.250.252.1:43002/oauth/token net::ERR_CERT_AUTHORITY_INVALID jquery-3.3.1.min.js:2
使用axios:
POST https://10.250.252.1:43002/oauth/token net::ERR_CERT_AUTHORITY_INVALID jquery-3.3.1.min.js:2
及
我使用的代码是:
$.ajax({
method:"POST",
url: `https://10.250.252.1:43002/oauth/token`,
contentType:"application/json; charset=utf-8",
data: {
grant_type:"password",
username:'user',
password:'user',
client_id:'11111111111111111',
client_secret:'1111'
}
}).done(
function(response) {
console.log(response);
});
axios.request({
url: "https://10.250.252.1:43002/oauth/token",
method: "post",
'content-type':'application/x-www-form-urlencoded',
auth: {
username: "user",
password: "user"
},
data: {
grant_type: "password",
client_id:'11111111111111111',
client_secret:'1111',
scope: "public"
}
})
.then(function(res) {
console.log(res);
});
它的SSL证书错误您需要首先在地址栏中打开URL并将证书导入浏览器。我刚刚做了-启动chrome时忽略证书错误
$.ajax({
method:"POST",
url: `https://10.250.252.1:43002/oauth/token`,
contentType:"application/json; charset=utf-8",
data: {
grant_type:"password",
username:'user',
password:'user',
client_id:'11111111111111111',
client_secret:'1111'
}
}).done(
function(response) {
console.log(response);
});
axios.request({
url: "https://10.250.252.1:43002/oauth/token",
method: "post",
'content-type':'application/x-www-form-urlencoded',
auth: {
username: "user",
password: "user"
},
data: {
grant_type: "password",
client_id:'11111111111111111',
client_secret:'1111',
scope: "public"
}
})
.then(function(res) {
console.log(res);
});