Skip to content

Commit 4ab3a21

Browse files
Aaron AlanizTim MendozaAlton09
authored
Add token server documentation (#9)
* Initial commit * Initial commit * Move helpers folder * Revert "Move helpers folder" This reverts commit d37d82b. * Update package name * Add error codes to function * Fix bugs * Update some copy * Update function responses * Update function responses * Fix json response in function * Apply PR feedback * Rename token server again * Rename destroy to delete-app * Add delete-app * More changes * Fix asset issue * Copy update * Add getPin test * Add default Circle CI node config * Trigger build * Add deps to fix cli errors with brew * Fix Object.assign issues * Delete refresh command * Remove code for refreshing passcodes * Deploy-app will redeploy app if one already exists * Remove unused variable * Update package-lock * Install jest * Add some tests for helpers * Add tests for video-token-server * Add e2e tests * Fix some things * Add --override flag to deploy-app command * AHOYAPPS-426 Add command documentation (#4) * Add command documentation * Add override example * Fix typo * Fix copy * Add prettier and husky * Run prettier * Remove static class properties * Add more unit tests * Add e2e test * Add eslint * Fix tests * Fix tests * Update command usage * Add error messages to token server * Completely redo e2e tests * Update some tests * Update error codes * Remove newlines * Update lint script * Rename commands * Add function to validate app-directory * Add tests for app-directory validation * Remove .only from test * Fix e2e test * Add readme (#5) * Get started on readme * Make override flag optional * Update readme sections * Update readme with new commands * Add VS code rulers * Address feedback Co-authored-by: Aaron Alaniz <[email protected]> * Use readdirSync in verifyAppDirectory * Add token server documentation * Update README.md Co-Authored-By: John Qualls <[email protected]> * Fix broken link * Update README.md Co-Authored-By: timmydoza <[email protected]> * Fix success response docs * Address feedback * Update table bg * Fix bg one more time * Update Circle CI badge syntax Co-authored-by: Tim Mendoza <[email protected]> Co-authored-by: John Qualls <[email protected]>
1 parent 435c6e1 commit 4ab3a21

File tree

1 file changed

+110
-8
lines changed

1 file changed

+110
-8
lines changed

README.md

Lines changed: 110 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# @twilio-labs/plugin-rtc
22

3-
[![CircleCI](https://circleci.com/gh/twilio-labs/plugin-rtc/tree/master.svg?style=svg&circle-token=df6c2750596f1000c1cf13e45dc314e00f0a2204)](https://circleci.com/gh/twilio-labs/plugin-rtc/tree/master)
3+
[![CircleCI](https://circleci.com/gh/twilio-labs/plugin-rtc.svg?style=svg)](https://circleci.com/gh/twilio-labs/plugin-rtc)
44

55
This plugin adds functionality to the [Twilio CLI](https://github.com/twilio/twilio-cli) which supports developing and deploying real-time communication apps.
66

77
* [Getting Started](#getting-started)
88
* [Supported Apps](#supported-apps)
99
* [Commands](#commands)
1010

11-
# Getting Started
11+
## Getting Started
1212

13-
## Install the Twilio CLI
13+
### Install the Twilio CLI
1414

1515
Via `npm` or `yarn`:
1616

@@ -27,25 +27,127 @@ $ brew tap twilio/brew && brew install twilio
2727

2828
See the [Twilio CLI documentation](https://www.twilio.com/docs/twilio-cli/quickstart) for more information.
2929

30-
## Install the plugin
30+
### Install the plugin
3131

3232
```sh-session
3333
$ twilio plugins:install @twilio-labs/plugin-rtc
3434
```
3535

36-
# Supported Apps
36+
## Supported Apps
3737

3838
This plugin currently supports the following applications:
3939

40-
## Twilio Video App
41-
A mobile and web collaboration application built with Programmable Video. Visit the projects below for instructions on how to use this plugin to build and deploy the Twilio Video app.
40+
### Twilio Video App
41+
42+
A mobile and web collaboration application built with Twilio Programmable Video. Visit the projects below for instructions on how to use this plugin to build and deploy the Twilio Video app.
4243

4344
* [React App](https://github.com/twilio/twilio-video-app-react)
4445
* [iOS App](https://github.com/twilio/twilio-video-app-ios)
4546
* [Android App](https://github.com/twilio/twilio-video-app-android)
4647

48+
#### Token Server API Documentation
49+
50+
The following section documents the application [token server](/src/video-token-server.js) used to provide [Programable Video access tokens](https://www.twilio.com/docs/video/tutorials/user-identity-access-tokens) to supported Twilio Video applications. The token server is deployed as a [Twilio Function](https://www.twilio.com/docs/runtime/functions).
51+
52+
| Method | URL |
53+
| --- | --- |
54+
| POST | [`/token`](#token) |
55+
56+
##### Authentication
57+
58+
The application token server requires an [authentication mechanism](#twilio-rtcappsvideodeploy---authentication-auth) to be specified when deploying. The following section documents each support authentication mechanism.
59+
60+
###### Passcode
61+
62+
Each request is verified using a passcode generated at deploy time. Passcodes remain valid for one week. After the passcode expires, users can redeploy an application and a new passcode will be generated. The snippet below provides an example request body used by a supported application.
63+
64+
```
65+
{
66+
"passcode": "1234564321",
67+
"user_identity": "User",
68+
"room_name": "Demo",
69+
}
70+
```
71+
72+
##### Token
73+
74+
Returns a Programmable Video Access token.
75+
76+
```shell
77+
POST /token
78+
```
79+
80+
###### Parameters
81+
82+
| Name | Type | Description |
83+
| --- | --- | --- |
84+
| `passcode` | `string` | **Required**. The application passcode. |
85+
| `user_identity` | `string` | **Required**. The user's identity. |
86+
| `room_name` | `string` | A room name that will be used to create a token scoped to connecting to only one room. |
87+
88+
###### Success Responses
89+
90+
<table>
91+
<tr>
92+
<td> <b>Status</b> </td> <td> <b>Response</b> </td>
93+
</tr>
94+
<tr>
95+
<td> 200 </td>
96+
<td>
97+
98+
```json
99+
{
100+
"token": "0000000000000000.0000000000000000000000.00000000000000000"
101+
}
102+
```
103+
104+
</td>
105+
</tr>
106+
107+
</table>
108+
109+
###### Error Responses
110+
111+
<table>
112+
<tr>
113+
<td> <b>Status</b> </td> <td> <b>Response</b> </td>
114+
</tr>
115+
116+
<tr>
117+
<td> 401 </td>
118+
<td>
119+
120+
```json
121+
{
122+
"error": {
123+
"message": "passcode expired",
124+
"explanation": "The passcode used to validate application users has expired. Re-deploy the application to refresh the passcode."
125+
}
126+
}
127+
```
128+
129+
</td>
130+
</tr>
131+
132+
<tr>
133+
<td> 401 </td>
134+
<td>
135+
136+
```json
137+
{
138+
"error": {
139+
"message": "passcode incorrect",
140+
"explanation": "The passcode used to validate application users is incorrect."
141+
}
142+
}
143+
```
144+
145+
</td>
146+
</tr>
147+
148+
</table>
47149

48-
# Commands
150+
## Commands
49151
<!-- commands -->
50152
* [`twilio rtc:apps:video:delete`](#twilio-rtcappsvideodelete)
51153
* [`twilio rtc:apps:video:deploy --authentication <auth>`](#twilio-rtcappsvideodeploy---authentication-auth)

0 commit comments

Comments
 (0)