surveymonkey-提供的授权令牌无效

时间:2019-05-07 08:24:47

标签: node.js surveymonkey

我正在尝试在NodeJS中获取serveymonkey响应。 这是我得到的答复:

{ 
error:
   { docs: 'https://developer.surveymonkey.com/api/v3/#error-codes',
     message: 'The authorization token provided was invalid.',
     id: '1011',
     name: 'Authorization Error',
     http_status_code: 401 
    } 
}

这是我的代码:

 const fetch = require('node-fetch');
  const accessToken = 'xxxxxxx';
 let options = {
   method : 'GET',
   headers: {
       Authorization: accessToken,
   },
   contentType: 'application/json'
   };

fetch('https://api.surveymonkey.com/v3/surveys/6991347309/responses/6991347309',options)
   .then(res => res.json())
   .then(json => console.log(json));

我多次检查访问令牌,然后直接从应用程序中复制了它。

我在做什么错了?

1 个答案:

答案 0 :(得分:1)

您在请求的Authorization标头中缺少前缀 bearer

Authorization: bearer YOUR_ACCESS_TOKEN

有关更多信息,请参阅API文档的Authentication部分。

相关问题