【发布时间】:2019-08-10 00:33:41
【问题描述】:
我正在向服务器发送一个POST 请求,以通过axios 获取一个令牌,其中Content-Type 标头为x-www-form-urlencoded。我对邮递员进行了同样的尝试,并且效果很好。我在请求正文中发送了一个 grant_type 和 client_credentials 的键值对。
这是我的 axios 请求:
axios.post(`${baseURI}/protocol/openid-connect/token`, data, {
headers : {
"Authorization" : "Basic " + token,
"Content-Type" : "application/x-www-form-urlencoded"
},
withCredentials: true
}).then(response => {
AUTH_TOKEN = response.data.access_token;
console.log(response.data);
}).catch(error => {
console.log(error.response);
})
数据对象由client_credentials组成。相同的凭据在邮递员中给出了成功的响应。
【问题讨论】: