I am trying video call using Twilio but I am getting issue when I am trying to get access token, In Twilio we can not make a video call without access token.

Can you guy's suggest me how we can get access token using REST API.

I have tried but not success.

I am getting below error:-

{"code": 20404, "message": "The requested resource /2010-04-01/Accounts/AC39270a782801db8da282e5ed88b0bbc3/authorize/token.json was not found", "more_info": "https://www.twilio.com/docs/errors/20404", "status": 404}

I think this issue is due to end point so please help me to solve this issue.

HTTP Request:-

public void authorizeTwillio(){

        String VERSION  = '3.2.0';
        Http htp = new Http();
        HttpRequest request = new HttpRequest();
        HttpResponse response = new HttpResponse();

        ConversationsGrant grant = new ConversationsGrant();

        String path = endpoint + '/2010-04-01/Accounts/' + this.twilioAccountSid + '/authorize/token.json';
        URL uri = new URL(path);

        request.setHeader('X-Twilio-Client', 'salesforce-' + VERSION);
        request.setHeader('User-Agent', 'twilio-salesforce/' + VERSION);
        request.setHeader('Accept', 'application/json');
        request.setHeader('Accept-Charset', 'utf-8');
        request.setHeader('Authorization', 'Basic '+EncodingUtil.base64Encode(Blob.valueOf(this.twilioAccountSid + ':' + this.twilioAuthToken)));

        response = htp.send(request);

        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Info,response.getBody()));


Thanks in advance.

  • Post your http request too.
    – Reshma
    Commented Jan 18, 2017 at 11:24
  • Are you able to make the call using the Postman? I believe you are hitting something else. Commented Jan 18, 2017 at 11:25
  • I have added HTTP request code..
    – user9839
    Commented Jan 18, 2017 at 13:18
  • Looks like we updated the thread at the same time. Based on the request - I see you aren't using the Twilio Salesforce lib, the easiest way to avoid such issues and without reinventing the wheel would be to use their Apex lib- twilio.com/docs/libraries/salesforce Commented Jan 18, 2017 at 13:20

1 Answer 1


Although you did not post your actual rqeuest code, the error is quiet clear from the response.

A) The error code returned is 20404 - Twilio API usually returns this error when a resource is not found

B) All Twilio APIs use the concept of returning resource representations as JSON. So an endpoint such as /2010-04-01/Accounts/AC30947.../IncomingPhoneNumbers/PN12345567789AFE4433 is equivalent to /2010-04-01/Accounts/AC30947.../IncomingPhoneNumbers/PN12345567789AFE4433.json

Based on the URL that's formed, it does not look like a valid endpoint. See this tutorial on how to authenticate using an access token.

  • I have read the tutorial but there are no end point is given so can you tell me which end point I need to use to solve this issue.
    – user9839
    Commented Jan 18, 2017 at 13:15
  • Twilio provides specific libraries which encapsulate these endpoints into methods. You did not mention it but if you are using the Salesforce library, this is handled by TwilioRestClient. Read more here - twilio-salesforce.readthedocs.io/en/latest/usage/basics.html Commented Jan 18, 2017 at 13:18
  • I have also added HTTP request code.
    – user9839
    Commented Jan 18, 2017 at 13:18
  • Is this possible using Rest Api?
    – user9839
    Commented Jan 18, 2017 at 13:23
  • These are REST API, I suggest you read up on the documentation and the provided links. There are some code samples which you can reuse. Commented Jan 18, 2017 at 13:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .