twilio-labs / plugin-token

Twilio CLI plugin for generating access tokens for Twilio Chat, Video, etc.
MIT License
5 stars 14 forks source link

twilio token:voice --identity=alice --voice-app-sid=AP40f04d5c678c9fd3a3b5add1724395e8 -l debug #61

Open Gangadhar1806 opened 2 months ago

Gangadhar1806 commented 2 months ago

Error is

[DEBUG] Config File: /Users/ganga.k/.twilio-cli/config.json [DEBUG] Using profile: Twilio_Staging_Mobile [DEBUG] Found command "token:voice" plugin: @twilio-labs/plugin-token » twilio-cli encountered an unexpected error. To report this issue, execute the command with the "-l debug" flag, then copy the output to a new issue here: "https://github.com/twilio-labs/plugin-token/issues" [DEBUG] identity is required to be specified in options [DEBUG] Error: identity is required to be specified in options at new AccessToken (/Users/ganga.k/.twilio-cli/node_modules/twilio/lib/jwt/AccessToken.js:28:19) at VoiceTokenGenerator.createToken (/Users/ganga.k/.twilio-cli/node_modules/@twilio-labs/plugin-token/src/helpers/accessToken.js:14:23) at VoiceTokenGenerator.run (/Users/ganga.k/.twilio-cli/node_modules/@twilio-labs/plugin-token/src/commands/token/voice.js:17:37) at async VoiceTokenGenerator._run (/Users/ganga.k/.twilio-cli/node_modules/@oclif/command/lib/command.js:43:20) at async Config.runCommand (/Users/ganga.k/.npm-global/lib/node_modules/twilio-cli/node_modules/@oclif/core/lib/config/config.js:301:25) › Error: EEXIT: 1 › Code: EEXIT

yigitcan-dh commented 2 months ago

I had the same error following the quickstart guide for the ios application. Seems like this CLI plugin is outdated and is misusing the Twilio lib's JWT access token generation.

Changing the ~/.twilio-cli/node_modules/@twilio-labs/plugin-token/src/helpers/accessToken.js file

From:

const accessToken = new Twilio.jwt.AccessToken(
  this.twilioClient.accountSid,
  this.twilioClient.username,
  this.twilioClient.password
);

To:

const accessToken = new Twilio.jwt.AccessToken(
  this.twilioClient.accountSid,
  this.twilioClient.username,
  this.twilioClient.password,
  { identity: this.flags.identity }
);

fixes it.

CongLeSolutionX commented 2 months ago

I had the same error following the quickstart guide for the ios application. Seems like this CLI plugin is outdated and is misusing the Twilio lib's JWT access token generation.

Changing the ~/.twilio-cli/node_modules/@twilio-labs/plugin-token/src/helpers/accessToken.js file

From:

const accessToken = new Twilio.jwt.AccessToken(
  this.twilioClient.accountSid,
  this.twilioClient.username,
  this.twilioClient.password
);

To:

const accessToken = new Twilio.jwt.AccessToken(
  this.twilioClient.accountSid,
  this.twilioClient.username,
  this.twilioClient.password,
  { identity: this.flags.identity }
);

fixes it.

This also worked for me! Thanks