1

我可以使用 curl 发出 oauth 请求,但使用 axios 我收到有关缺少使用者密钥的错误

X-Error 缺少消费者密钥。

这发生在发出请求的 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/\"}"
4

1 回答 1

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/'
    }
});
于 2018-09-16T18:18:24.947 回答