【问题标题】:Set bearer token in NodeJS在 NodeJS 中设置不记名令牌
【发布时间】:2018-10-27 04:31:29
【问题描述】:

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

感谢您的帮助:)

【问题讨论】:

  • 您能详细说明您使用的是什么吗?是 Node.js 还是 PHP?您是否尝试从客户端或服务器到服务器 API 调用进行 API/AJAX 调用?

标签: node.js bearer-token


【解决方案1】:

我在node js中这样创建,然后在你的.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);
      }
}

【讨论】:

    猜你喜欢
    • 2021-09-19
    • 2020-03-20
    • 2020-11-15
    • 1970-01-01
    • 2021-11-05
    • 1970-01-01
    • 2018-10-10
    • 1970-01-01
    • 2022-08-15
    相关资源
    最近更新 更多