Reputation: 186
So currently we have a master account and multiple sub accounts on twilio. We are trying to implement Client Access Tokens, and these require (among many other things) an api key and an api secret.
We already tried using the master api key but it returns an authentication error (invalid token) when we use it with the a twiml app on a sub account is there any way to generate an api key via the restful api on twilio??
Much appreciated
Upvotes: 1
Views: 825
Reputation: 186
I was able to finally reach out to twilio support staff and they were very helpfull and were able to provide me with an answer.
use Twilio\Rest\Client;
// Find your Account Sid and Auth Token at twilio.com/console
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$twilio = new Client($sid, $token);
$key = $twilio->newKeys->create(array("FriendlyName" => "New Key from PHP"));
print($key->sid . "\n");
print($key->secret . "\n");
and for nodejs:
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);
client.newKeys.create({friendlyName: 'New Key from Node.js'})
.then(key => console.log(key.sid,key.secret));
apparantly the answer is not yet added into documentation.
Upvotes: 3