简体   繁体   English

在NodeJS中设置承载令牌

[英]Set bearer token in NodeJS

I have a web backend using NodeJS. 我有一个使用NodeJS的Web后端。 I want to retrieve data from another server using a link eg https://evoDMSTDev/api/api_event_all.php , and must use a bearer token eg 71D55F6907509 to access it. 我想使用链接(例如https://evoDMSTDev/api/api_event_all.php从另一台服务器检索数据,并且必须使用承载令牌(例如71D55F6907509来访问它。 So, where I have to set the token so I can retrieve that data and display it on my web backend? 因此,我必须在哪里设置令牌以便可以检索该数据并将其显示在Web后端上?

Thank you for your help :) 谢谢您的帮助 :)

I create like this in node js, and then just call the obj in your .ejs 我在节点js中创建这样的obj ,然后在.ejs调用obj

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);
      }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM