Generate and Assign Token Roles using the Video API | One Dev Minute
Published on September 15, 2021

Welcome to One Dev Minute! This series is hosted on the Vonage Dev YouTube channel. The goal of this video series is to share knowledge in a bite-sized manner.

In this video, Amanda Cavallaro, our Developer Advocate, shows you how the token roles allow you to identify users and change the permission roles using the Vonage Video API.

Transcript

Hi! This is Amanda Cavallaro, a Developer Advocate at Vonage, and today I'll talk about generating and assigning token roles.

To authenticate a user connecting to a video API session we must use a  unique authentication key called "token".

There are three possible token roles: subscriber, publisher, and moderator.

Let's generate a token using the video API Node.js server-side library.

We first install Opentok from the terminal. In your coding editor, you set the constants with the  API key and the API secret that you receive when you sign up to use the video API.

You can create or use an existing session ID. Next, we call the generateToken method that will return a token in the string format.

You can generate tokens for clients to use when connecting to the session. In this example, we are creating a username "Amanda" of role "publisher".

The options parameter is an optional object used to set the role, expiry time, and connection data of the token. We then add the token options to the generated token, run Node and the name of the file we created and in your terminal, you can see your token.

There are a number of things you can do with your generated token depending on its role. You have additional permissions if you receive a moderator token. You can, for instance, disconnect, mute other users, or even stop publishing their streams.

In this video, you saw how to generate and design a token. You can learn further from the links below!

Code present in this video

Capabilities

Create Token

Join the Vonage Developer Community Slack

Amanda CavallaroDeveloper Advocate

Ready to start building?

Experience seamless connectivity, real-time messaging, and crystal-clear voice and video calls-all at your fingertips.

Subscribe to Our Developer Newsletter

Subscribe to our monthly newsletter to receive our latest updates on tutorials, releases, and events. No spam.