Coder Social home page Coder Social logo

video-access-token-server-node's Introduction

Twilio

Video Access Token Server for Node.js

Node.js CI

Looking for the JavaScript Video Quickstart? It has been moved here.

This server-side application demonstrates generating Access Token for Twilio Video. Before we begin, we need to collect all the config values we need to run the application:

Config Value Description
Account SID Your primary Twilio account identifier - find this in the console here.
API Key Used to authenticate - generate one here.
API Secret Used to authenticate - just like the above, you'll get one here.

A Note on API Keys

When you generate an API key pair at the URLs above, your API Secret will only be shown once - make sure to save this in a secure location, or possibly your ~/.bash_profile.

Setting up the Node.js Application

Create a configuration file for your application:

cp .env.example .env

Edit .env with the three configuration parameters we gathered from above.

Next, we need to install our dependencies from npm:

npm install

Now we should be all set! Run the application using the node command.

node .

To generate Access Token, visit http://localhost:3000?identity=alice&room=example.

Run tests

npm test

Meta

  • No warranty expressed or implied. Software is as is. Diggity.
  • MIT License
  • Lovingly crafted by Twilio Developer Education.

video-access-token-server-node's People

Contributors

alejandrovivanco0o avatar alexisbcc avatar atbaker avatar daniakash avatar dependabot-preview[bot] avatar dprothero avatar eddiezane avatar innerverse avatar jefflinwood avatar jonathanazulay avatar ktoraskartwilio avatar kwhinnery avatar llsourcell avatar manjeshbhargav avatar markandrus avatar nebtrx avatar rfbrazier avatar sarahcstringer avatar smendes avatar well1791 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

video-access-token-server-node's Issues

Should mention Account SID must be Live

Hi,

I tried with the Test Account SID, but there was always a Gateway error. Then I shifted to Live and everything works like a charm.

I think it might be better to mention this in the README.

Thanks

how can i set the expire time?

i want to set the expire time, please suggest me about the time limits and where to put? if you can share a code sample is fine.

JavaScript formatting

Getting closer - in the client-side JS, sometimes you use four space tabs, sometimes two. Need to be consistent. Should leave once space between the // comment and the content of the comment, like the preceding. Also, the indentation and scope nesting of the Ajax call is awkward. Should be (if you use four space tabs):

var identity; // since we need this in other scopes

$.getJSON('/token', function(data) {
    identity = data.identity;
    var accessManager = new Twilio.AccessManager(data.token);

    // Check the browser console to see your generated identity. 
    // Send an invite to yourself if you want! 
    console.log(identity);

    // create a Conversations Client and connect to Twilio
    conversationsClient = new Twilio.Conversations.Client(accessManager);
    conversationsClient.listen().then(clientConnected, function (error) {
        log('Could not connect to Twilio: ' + error.message);
    });
});

function clientConnected() {
  // all other logic
}

HTML Formatting

The indentation is incorrect in the index.html file - should be

<!DOCTYPE html>
<html>
<head>
  <title>Twilio Video - Video Quickstart</title>
  <link rel="stylesheet" href="https://media.twiliocdn.com/sdk/quickstart/conversations-quickstart.min.css">
</head>
<body>
  <div id="remote-media"></div>
  <div id="controls">
    <div id="preview">
      <p class="instructions">Hello Beautiful</p>
      <div id="local-media"></div>
      <button id="button-preview">Preview My Camera</button>
    </div>
    <div id="invite-controls">
      <p class="instructions">Invite another Video Client</p>
      <input id="invite-to" type="text" placeholder="Identity to send an invite to" />
      <button id="button-invite">Send Invite</button>
    </div>
    <div id="log">
      <p>&gt;&nbsp;<span id="log-content">Preparing to listen</span>...</p>
    </div>
  </div><!-- /controls -->
  <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
  <script src="https://media.twiliocdn.com/sdk/js/common/v0.1/twilio-common.min.js"></script>
  <script src="https://media.twiliocdn.com/sdk/js/conversations/v0.11/twilio-conversations.min.js"></script>
  <script src="quickstart.js"></script>
</body>
</html>

Convert all tabs to spaces

In the index.js source file (the server), there are a few tabs where there should be spaces under token.identity = identity;

Under Firefox

Hello,

I am managing to make use of the code sample without any issue under Chrome. Under Firefox however, big issues appear:

  • Video gives only the first image and freezes.
  • Everything stops after 15 secs or so, without the "disconnect" event being ever fired.
    My hunch is that WebRTC is the culprit, but this is only a hunch.

Any hints?

Illegal constructor

Hi- When I want to run the demo, I see the following error in my browser:
"Could not connect to Twilio. Illegal constructor."
What could be the reason?

Found some Syntax Errors

Hi,

I have Found Following Syntax Errors in the module.

First One:
conversationsClient.listen().then(clientConnected, function (error) {
look at the above line. here, the function clientConnected is called without parenthesis

and the Right way is
conversationsClient.listen().then( clientConnected() , function (error) {

Second One:
conversationsClient.inviteToConversation(inviteTo, options).then(conversationStarted, function (error) {

Here, the function conversationStarted is called without parenthesis, also parameter conversation is not passed

and the Right way is
conversationsClient.inviteToConversation(inviteTo, options).then(conversationStarted(conversationParameter), function (error) {

and I don't know what to pass as conversationParameter. If anyone knows, Please let me know.

Really lost here.

I am attempting to implement the Twilio Video Node.js SDK, and there seems to be 100+ different tutorials, blog posts, etc, that all handle the token generation differently(and the Twilio SDK as a whole for that matter).

I have seen these two methods, plus some more weird ones during my search.

token = new twilio.AccessToken(apiKeySid, accountSid, apiKeySecret);

Twilio.tokens.create((err, response) => {
            if(err){
                console.error('Twilio Create Token Error: ', err);
                                // disregard the Boom error object. 
                return reply(Boom.badImplementation(err));
            }

        });

Is there a definitive way for me to create a user token, have the user attach to Twilio with that token?

Twilio Version 3.0.0-rc.11 Cannot read property 'ConversationsGrant' of undefined

I tried to clone this project and run npm install (no errors encountered)
then node . and this is what happens

/index.js:13
var ConversationsGrant = AccessToken.ConversationsGrant;
                                    ^

TypeError: Cannot read property 'ConversationsGrant' of undefined
    at Object.<anonymous> (/home/username/Projects/twilio-video-tutorial/video-quickstart-node-master/index.js:13:37)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Function.Module.runMain (module.js:441:10)
    at startup (node.js:139:18)
    at node.js:968:3

I happen to also clone this project a month ago and running npm install then node . managed to run the project successfully and video call is working as expected. Upon checking that version, it's using 3.0.0-rc.9

There might be something wrong with 3.0.0-rc.11.

Could not connect to Twilio: Connect failed

When trying to connect to Twilio under a new setup, I get "Connect failed". I've browsed around and this is different then the undefined error listed elsewhere. I've tried a LIVE and Test ID, neither seem to be working.

Generating my own token through the website and pasting it in solves the problem, but I would like a solution that could generate it's own token.

Browser: Chrome & Firefox
OS: OSX
Steps to reproduce:

  1. brew install node
  2. cp .env.example .env
  3. Set variables
  4. npm install
  5. node .
  6. Connect to a channel

Audio?

Video seems to work fine, but I don't have audio in this example. Does the mic need to be set-up separately or is this an issue on my end?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.