This is a service to generate a Twilio Access Token, using Twilio Functions. The token provides grant for Chat and Video. Created using Twilio official guide.
- A Twilio Account
- Twilio account SID
- Twilio account Auth Token
- An API Key
- An API Secret
- A Chat Service SID
- Install
twilio-cli
npm install twilio-cli -g
- Add the Twilio Serverless Toolkit plugin
twilio serverless:init token-service
- Login into the Twilio CLI
This will prompt you for your account credentials including your Account SID and your Auth Token, both of which are available on your Twilio Console dashboard.
twilio login
- Clone the repository
git clone https://github.com/marsidev/twilio-token-service cd twilio-token-service
- Install dependencies
npm install
- Create an
.env
file in the root of the project and add the following variables:ACCOUNT_SID= API_KEY= API_SECRET= SERVICE_SID=
- Update the
Access-Control-Allow-Origin
infunctions/token.js
- Deploy to Twilio:
twilio serverless:deploy
- Use the service:
curl token-service-XXXX-dev.twil.io/token