在NodeJS中设置承载令牌

时间:2018-05-17 02:16:23

标签: node.js bearer-token

我有一个使用NodeJS的网络后端。我想使用链接(例如https://evoDMSTDev/api/api_event_all.php)从另一台服务器检索数据,并且必须使用承载令牌(例如71D55F6907509)来访问它。那么,我必须设置令牌,以便我可以检索该数据并将其显示在我的网络后端?

感谢您的帮助:)

1 个答案:

答案 0 :(得分:0)

我在节点js中这样创建,然后只需在您的obj中调用.ejs

request({
    uri : 'https://evoDMSTDev/api/api_events_all.php',
    auth: {
        'bearer': '71D55F99570209'
    },
    rejectUnauthorized: false,//add when working with https sites
    requestCert: false,//add when working with https sites
    agent: false,//add when working with https sites
}, function(error, response, body) {
      if (error) {
         console.log(error);
      } else {
         obj = JSON.parse(body);
      }
}