我可以使用 curl 发出 oauth 请求,但使用 axios 时我收到有关缺少使用者密钥的错误
X 错误 缺少使用者密钥。
这发生在发出请求的 OPTIONS 阶段。
axios({
method: 'post',
url: 'https://getpocket.com/v3/oauth/request',
data: {
'consumer_key': 'xxxx-xxxxxxxxxxxxxxx',
'redirect_uri': 'http://localhost:8080/'
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.18.0/axios.min.js"></script>
这是卷曲请求
curl https://getpocket.com/v3/oauth/request --insecure -X POST -H "Content-Type: application/json" -H "X-Accept: application/json" -d "{"consumer_key":"xxxx-xxxxxx","redirect_uri":"http://localhost:8080/"}"
尝试将标头添加到您的请求中,使其接受 json:
axios({
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json;charset=UTF-8'
},
url: 'https://getpocket.com/v3/oauth/request',
data: {
'consumer_key': 'xxxx-xxxxxxxxxxxxxxx',
'redirect_uri': 'http://localhost:8080/'
}
});