NodeJS 502错误网关Twilio

g52tjvyc  于 2023-02-21  发布在  Node.js
关注(0)|答案(1)|浏览(166)

嗨evreyone我使用twilio语音javascript sdk与ngrok,我发现他们的存储库在github安装进行良好,当我试图点击启动divice从我的名称生成器js获得客户端名称时,一个错误已经显示,我无法获得客户端名称或进行任何调用
我已使用所有帐户SID电话号码twiml应用程序SIDTwilio API密钥设置了索引js

命令错误

Error: identity is required to be specified in options
    at new AccessToken (C:\xampp\htdocs\voice-javascript-sdk-quickstart-node\node_modules\twilio\lib\jwt\AccessToken.js:202:19)
    at tokenGenerator (C:\xampp\htdocs\voice-javascript-sdk-quickstart-node\src\handler.js:13:23)
    at C:\xampp\htdocs\voice-javascript-sdk-quickstart-node\src\router.js:7:12
    at Layer.handle [as handle_request] (C:\xampp\htdocs\voice-javascript-sdk-quickstart-node\node_modules\express\lib\router\layer.js:95:5)    at next (C:\xampp\htdocs\voice-javascript-sdk-quickstart-node\node_modules\express\lib\router\route.js:144:13)
    at Route.dispatch (C:\xampp\htdocs\voice-javascript-sdk-quickstart-node\node_modules\express\lib\router\route.js:114:3)
    at Layer.handle [as handle_request] (C:\xampp\htdocs\voice-javascript-sdk-quickstart-node\node_modules\express\lib\router\layer.js:95:5)    at C:\xampp\htdocs\voice-javascript-sdk-quickstart-node\node_modules\express\lib\router\index.js:284:15
    at Function.process_params (C:\xampp\htdocs\voice-javascript-sdk-quickstart-node\node_modules\express\lib\router\index.js:346:12)       
    at next (C:\xampp\htdocs\voice-javascript-sdk-quickstart-node\node_modules\express\lib\router\index.js:280:10)

ngrok错误当我单击启动设备

HTTP Requests
-------------

GET /quickstart.js             200 OK
GET /twilio.min.js             200 OK
GET /site.css                  200 OK
GET /                          200 OK
GET /                          502 Bad Gateway

配置js

const dotenv = require("dotenv");
const cfg = {};

if (process.env.NODE_ENV !== "test") {
  dotenv.config({ path: ".env" });
} else {
  dotenv.config({ path: ".env.example", silent: true });
}

// HTTP Port to run our web application
cfg.port = process.env.PORT || 3000;

// Your Twilio account SID and auth token, both found at:
// https://www.twilio.com/user/account
//
// A good practice is to store these string values as system environment
// variables, and load them from there as we are doing below. Alternately,
// you could hard code these values here as strings.
cfg.accountSid = process.env.TWILIO_ACCOUNT_SID;

cfg.twimlAppSid = process.env.TWILIO_TWIML_APP_SID;
cfg.callerId = process.env.TWILIO_CALLER_ID;

cfg.apiKey = process.env.TWILIO_API_KEY;
cfg.apiSecret = process.env.TWILIO_API_SECRET;

// Export configuration object
module.exports = cfg;
elcex8rz

elcex8rz1#

您是否尝试过记录cfg对象以查看它是否包含所有预期值?
可以在按如下方式结束config.js文件时执行此操作:

console.log(cfg);

// Export configuration object
module.exports = cfg;

相关问题