Eventbrite API无法使用nodejs创建事件,获取错误403 not_authorized响应

时间:2018-02-01 15:12:33

标签: node.js api eventbrite

我正在尝试使用API​​创建Eventbrite事件,这是我的代码

var request = require('request');
var EVENTBRITE_API_URL = 'https://www.eventbriteapi.com/v3/';
var _token = '<TOKEN>';

var _event = {
    "event.name.html": "TestEvent01",
    "event.description.html": "TestEvent01",
    "event.start.timezone": "America/Chicago",
    "event.start.utc": "2018-02-10T18:00:00Z",
    "event.end.timezone": "America/Chicago",
    "event.end.utc": "2018-02-10T20:00:00Z",
    "event.currency": "USD",
};

var request = require('request');
var _headers = {
    'Authorization': 'Bearer ' + _token,
    'Content-Type': 'application/x-www-form-urlencoded',
}

// Configure the request
var options = {
    url: EVENTBRITE_API_URL + "events/",
    method: 'POST',
    headers: _headers,
    form: _event,
};

request(options, function (error, response, body) {
  if (!error) {
    console.log(body);
  }
});

它没有工作,我收到了以下回复:

{"status_code": 403, "error_description": "You do not have permission to access the resource you requested.", "error": "NOT_AUTHORIZED"}

有人可以在这里说明错误。提前谢谢!

1 个答案:

答案 0 :(得分:1)

我不是节点专家,但这对我来说没问题。我猜你没有传递正确的令牌。您可以创建令牌here。您应在授权标头中传递的令牌字符串标记为您的个人OAuth令牌

干杯!