我正在尝试在Axios中发出相同的请求,但似乎不起作用。有人知道吗?
curl -X POST -vu CLIENT_ID:CLIENT_SECRET http://localhost:9001/oauth/token -d "grant_type=password&username=user&password=password"
在Axios中:
var reqData = "grant_type=password&username=username&password=password"
return axios.post("http://localhost:9001/oauth/token", reqData , {
headers: {
"Postman-Token": "4b7526c0-a204-4ad5-6194-49e0cd1bfd12",
"Cache-Control": "no-cache",
"Authorization": "Basic "+base64.encode(CLIENT_ID + ':' + CLIENT_SECRET),
"Content-Type": "application/x-www-form-urlencoded"
}
}).then(response => {
console.log(response)
return response})