我可以使用curl发出oauth请求,但是使用axios时,我会收到有关缺少使用者密钥的错误
X错误 缺少用户密钥。
这发生在发出请求的“选择”阶段。
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/\"}"
答案 0 :(得分:0)
尝试将标头添加到您的请求中以接受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/'
}
});