1

Hi evreyone Im using twilio voice javascript sdk with ngrok that i found their repository in github the installation went good when i try to click on start up the divice to get the client name from my name generator js an error has showed and i can not get the cleint client name or make any calls

i have set up my index js with all my account sid and phone number and twiml app sid and Twilio api secret key

cmd error

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 error when i click on start up the device

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

config.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;

1 Answers1

0

Have you tried logging the cfg object to see whether it contains all the expected values?

You can do this when you end the config.js file as follows:

console.log(cfg);

// Export configuration object
module.exports = cfg;
IObert
  • 2,118
  • 1
  • 10
  • 17
  • i`ve tried that and it shows me in console all my correct values such as port number / twilio account sid/ twiml app sid /caller id/api key/ api secret. and when i click on start up the device the same error show Error: identity is required to be specified in options – Abdellah Hajjam Feb 21 '23 at 10:15