Skip to main content

Authentication & Tokens

The SDK works with two types of token:

  • Management tokens authenticate your server-side API calls. The client generates and refreshes them automatically.
  • Participant tokens authorize a client application to join a room. You generate them on your server and pass them to the client.

Both are JSON Web Tokens (JWTs) signed locally with your secret, so generating one requires no network request.

Management tokens

Construct the client with your credentials and every request is authenticated automatically:

const client = new VideoSDK({ apiKey, secret });

The token is sent as a raw JWT in the Authorization header, with no Bearer prefix.

Participant tokens

Generate a participant token on your backend and pass it to the client SDK to join a room. Use the access-token builder:

const token = client
.accessToken()
.setParticipant("user-123")
.grant(Grant.AllowJoin, Grant.AllowMod)
.forRoom("abcd-efgh-ijkl")
.expiresIn("2h")
.toJwt();

Each method sets one property of the token: setParticipant the participant id, grant the permissions, forRoom an optional room scope, and expiresIn the expiry. toJwt then signs it with your secret and returns the token string. To build a management token instead of a participant token, replace forRoom with forApi / ForAPI.

Grants control what the participant may do:

GrantMeaning
AllowJoinJoin the meeting directly.
AskJoinRequest to join. A host admits them.
AllowModModerate others: toggle their mic/camera, remove them.

Without a grant, the token defaults to allow_join and allow_mod.

For a full explanation of participant permissions and join modes, see Permissions and modes.

Generate a token directly

Skip the builder when you just need a management token:

const apiToken = client.generateToken({ expiresIn: "1h" });

Verify a token

Returns the decoded claims, or an authentication error if the token is invalid or expired:

const claims = client.verifyToken(token);

The decoded payload contains:

FieldTypeDescription
apikeystringThe API key the token was signed for.
permissionsstring[]Granted permissions (allow_join, allow_mod, …).
rolesstring[]Token roles assigned to the token.
versionnumberToken schema version.
iatnumberIssued-at time (epoch seconds).
expnumberExpiry time (epoch seconds).

Use a pre-generated token

Pass a token you already hold. The client uses it as-is and will not refresh it, so prefer an API key + secret for anything long-lived:

const client = new VideoSDK({ token });
tip

Paste any token into jwt.io to inspect its claims. For the full token model, see the authentication guide.

Got a Question? Ask us on discord