Dedicated Developer
Dedicated Developer

Reputation: 1

Getting error when calling using twilio sdk

I have to use twilio SDK for my calling app. I tried using the following code for which I am getting below error. Can you let me know the error I am facing? Error code coming is 20107. It comes when I try to place the call

const AccessToken = require('twilio').jwt.AccessToken;
const VoiceGrant = AccessToken.VoiceGrant;
const twilioAccountSid = xxx
const twilioApiKey = xxx
const twilioApiSecret = xxx

// Used specifically for creating Voice tokens
const outgoingApplicationSid = xxx
const identity = 'user';
// Create a "grant" which enables a client to use Voice as a given user
const voiceGrant = new VoiceGrant({
  outgoingApplicationSid: outgoingApplicationSid,
  incomingAllow: true, // Optional: add to allow incoming calls
});

// Create an access token which we will sign and return to the client,
// containing the grant we just created
const token = new AccessToken(
  twilioAccountSid,
  twilioApiKey,
  twilioApiSecret,
  {identity: identity}
);

token.addGrant(voiceGrant);

// Serialize the token to a JWT string
console.log(token.toJwt();

I have tried all the steps written on the twilio website but still facing the issue.

Upvotes: 0

Views: 25

Answers (0)

Related Questions