Skip to content
This repository was archived by the owner on May 13, 2025. It is now read-only.

Commit 40e9dbe

Browse files
author
Jozsef Vass
committed
update to access token server
1 parent 8b942ed commit 40e9dbe

26 files changed

+162
-623
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Ignore Web.config, which contains app keys
2-
VideoQuickstart/Web.config
2+
VideoAccessTokenServer/Web.config
33

44
## Ignore Visual Studio temporary files, build results, and
55
## files generated by popular Visual Studio add-ons.

README.md

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
# Video Quickstart for C# (ASP.NET MVC)
1+
# Video Access Token Server for C# (ASP.NET MVC)
22

3-
This application should give you a ready-made starting point for writing your
4-
own video apps with Twilio Video. Before we begin, we need to collect
3+
This server-side application demonstrates generating Access Token for Twilio Video.
4+
Before we begin, we need to collect
55
all the config values we need to run the application:
66

77
| Config Value | Description |
88
| :------------- |:------------- |
9-
Configuration Profile SID | Identifier for a set of config properties for your video application - [find yours here](https://www.twilio.com/console/video/profiles).
109
Account SID | Your primary Twilio account identifier - find this [in the console here](https://www.twilio.com/console).
1110
API Key | Used to authenticate - [generate one here](https://www.twilio.com/console/video/dev-tools/api-keys).
1211
API Secret | Used to authenticate - [just like the above, you'll get one here](https://www.twilio.com/console/video/dev-tools/api-keys).
@@ -17,26 +16,19 @@ When you generate an API key pair at the URLs above, your API Secret will only
1716
be shown once - make sure to save this in a secure location,
1817
or possibly your system environment variables.
1918

20-
## Setting Up The Application
19+
## Setting up the Application
2120

22-
After downloading the repo, copy the `VideoQuickstart/Web.config.example` to `Web.config` in the same directory. Next, open up `VideoQuickstart.sln` in Visual Studio. Edit `Web.config` with the four values we obtained above:
21+
After downloading the repo, copy the `VideoAccessTokenServer/Web.config.example` to `Web.config` in the same directory. Next, open up `VideoAccessTokenServer.sln` in Visual Studio. Edit `Web.config` with the three values we obtained above:
2322

2423
```xml
2524
<appSettings>
2625
<add key="TwilioAccountSid" value="ACxxx" />
2726
<add key="TwilioApiKey" value="SKxxx" />
2827
<add key="TwilioApiSecret" value="xxxxxxxx" />
29-
<add key="TwilioConfigurationSid" value="VSxxxx" />
3028
</appSettings>
3129
```
3230

33-
You should now be ready to rock! Hit `F5` or the Play button, and you should
34-
land on the home page of our basic chat application. Open it up in a few browser
35-
tabs and start video chatting with yourself! Note that Twilio video requires
36-
WebRTC enabled browsers, so Edge and Internet Explorer will not work for testing.
37-
We'd recommend Google Chrome or Mozilla Firefox instead.
38-
39-
![screenshot of chat app](https://s3.amazonaws.com/com.twilio.prod.twilio-docs/images/video2.original.png)
31+
To generate Access Token, hit `F5` or the Play button, and you should see the Access Token in your browser window.
4032

4133
## License
4234

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 14
4-
VisualStudioVersion = 14.0.23107.0
4+
VisualStudioVersion = 14.0.25420.1
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VideoQuickstart", "VideoQuickstart\VideoQuickstart.csproj", "{B49B870C-1522-4699-94DF-E153B3F25F5C}"
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VideoAccessTokenServer", "VideoAccessTokenServer\VideoAccessTokenServer.csproj", "{9E1836F8-E8DB-48FA-95BC-9918F1B0C064}"
77
EndProject
88
Global
99
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1010
Debug|Any CPU = Debug|Any CPU
1111
Release|Any CPU = Release|Any CPU
1212
EndGlobalSection
1313
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14-
{B49B870C-1522-4699-94DF-E153B3F25F5C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15-
{B49B870C-1522-4699-94DF-E153B3F25F5C}.Debug|Any CPU.Build.0 = Debug|Any CPU
16-
{B49B870C-1522-4699-94DF-E153B3F25F5C}.Release|Any CPU.ActiveCfg = Release|Any CPU
17-
{B49B870C-1522-4699-94DF-E153B3F25F5C}.Release|Any CPU.Build.0 = Release|Any CPU
14+
{9E1836F8-E8DB-48FA-95BC-9918F1B0C064}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{9E1836F8-E8DB-48FA-95BC-9918F1B0C064}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{9E1836F8-E8DB-48FA-95BC-9918F1B0C064}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{9E1836F8-E8DB-48FA-95BC-9918F1B0C064}.Release|Any CPU.Build.0 = Release|Any CPU
1818
EndGlobalSection
1919
GlobalSection(SolutionProperties) = preSolution
2020
HideSolutionNode = FALSE

VideoQuickstart/App_Start/RouteConfig.cs renamed to VideoAccessTokenServer/App_Start/RouteConfig.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,18 @@
55
using System.Web.Mvc;
66
using System.Web.Routing;
77

8-
namespace VideoQuickstart
8+
namespace VideoAccessTokenServer
99
{
1010
public class RouteConfig
1111
{
1212
public static void RegisterRoutes(RouteCollection routes)
1313
{
1414
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
1515

16-
routes.MapRoute(
17-
name: "Token",
18-
url: "token",
19-
defaults: new { controller = "Token", action = "Index" }
20-
);
21-
2216
routes.MapRoute(
2317
name: "Default",
2418
url: "{controller}/{action}/{id}",
25-
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
19+
defaults: new { controller = "Token", action = "Index", id = UrlParameter.Optional }
2620
);
2721
}
2822
}
Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,35 @@
1-
using System.Configuration;
1+
using System.Collections.Generic;
22
using System.Web.Mvc;
3-
using Faker;
3+
using System.Configuration;
44
using Twilio.Jwt.AccessToken;
5-
using System.Collections.Generic;
65

7-
namespace VideoQuickstart.Controllers
6+
namespace VideoAccessTokenServer.Controllers
87
{
98
public class TokenController : Controller
109
{
11-
// GET: /token
10+
// GET: Token
1211
public ActionResult Index()
1312
{
1413
// Load Twilio configuration from Web.config
1514
var accountSid = ConfigurationManager.AppSettings["TwilioAccountSid"];
1615
var apiKey = ConfigurationManager.AppSettings["TwilioApiKey"];
1716
var apiSecret = ConfigurationManager.AppSettings["TwilioApiSecret"];
18-
var videoConfigSid = ConfigurationManager.AppSettings["TwilioConfigurationSid"];
1917

2018
// Create a random identity for the client
21-
var identity = Internet.UserName();
19+
var identity = Request.QueryString["identity"] ?? "identity";
2220

2321
// Create a video grant for the token
2422
var grant = new VideoGrant();
25-
grant.ConfigurationProfileSid = videoConfigSid;
23+
grant.Room = Request.QueryString["room"];
2624
var grants = new HashSet<IGrant> { grant };
2725

2826
// Create an Access Token generator
2927
var token = new Token(accountSid, apiKey, apiSecret, identity: identity, grants: grants);
3028

3129
return Json(new
3230
{
33-
identity,
3431
token = token.ToJwt()
3532
}, JsonRequestBehavior.AllowGet);
3633
}
3734
}
38-
}
35+
}

VideoAccessTokenServer/Global.asax

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<%@ Application Codebehind="Global.asax.cs" Inherits="VideoAccessTokenServer.MvcApplication" Language="C#" %>
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
using System.Web.Mvc;
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Web;
5+
using System.Web.Mvc;
26
using System.Web.Routing;
37

4-
namespace VideoQuickstart
8+
namespace VideoAccessTokenServer
59
{
610
public class MvcApplication : System.Web.HttpApplication
711
{
812
protected void Application_Start()
913
{
1014
AreaRegistration.RegisterAllAreas();
11-
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
1215
RouteConfig.RegisterRoutes(RouteTable.Routes);
1316
}
1417
}

VideoQuickstart/Properties/AssemblyInfo.cs renamed to VideoAccessTokenServer/Properties/AssemblyInfo.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,34 @@
22
using System.Runtime.CompilerServices;
33
using System.Runtime.InteropServices;
44

5-
// General Information about an assembly is controlled through the following
5+
// General Information about an assembly is controlled through the following
66
// set of attributes. Change these attribute values to modify the information
77
// associated with an assembly.
8-
[assembly: AssemblyTitle("VideoQuickstart")]
8+
[assembly: AssemblyTitle("VideoAccessTokenServer")]
99
[assembly: AssemblyDescription("")]
1010
[assembly: AssemblyConfiguration("")]
1111
[assembly: AssemblyCompany("")]
12-
[assembly: AssemblyProduct("VideoQuickstart")]
13-
[assembly: AssemblyCopyright("Copyright © 2015")]
12+
[assembly: AssemblyProduct("VideoAccessTokenServer")]
13+
[assembly: AssemblyCopyright("Copyright © 2017")]
1414
[assembly: AssemblyTrademark("")]
1515
[assembly: AssemblyCulture("")]
1616

17-
// Setting ComVisible to false makes the types in this assembly not visible
18-
// to COM components. If you need to access a type in this assembly from
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
1919
// COM, set the ComVisible attribute to true on that type.
2020
[assembly: ComVisible(false)]
2121

2222
// The following GUID is for the ID of the typelib if this project is exposed to COM
23-
[assembly: Guid("b5d1c8ff-a8b5-454d-8a1e-369c12348d1d")]
23+
[assembly: Guid("9e1836f8-e8db-48fa-95bc-9918f1b0c064")]
2424

2525
// Version information for an assembly consists of the following four values:
2626
//
2727
// Major Version
28-
// Minor Version
28+
// Minor Version
2929
// Build Number
3030
// Revision
3131
//
32-
// You can specify all the values or you can default the Revision and Build Numbers
32+
// You can specify all the values or you can default the Revision and Build Numbers
3333
// by using the '*' as shown below:
3434
[assembly: AssemblyVersion("1.0.0.0")]
3535
[assembly: AssemblyFileVersion("1.0.0.0")]

0 commit comments

Comments
 (0)