Deploy an Agora RTC token server and join a video channel with token authentication

domain: docs.agora.io · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. In Agora Console, create a project and enable App Certificate to require token authentication; download or clone Agora's open-source token server reference implementation (AgoraDynamicKey on GitHub) in your preferred language.
  2. On your server, implement a token generation endpoint that accepts appId, appCertificate, channelName, and uid; use the RtcTokenBuilder from the SDK to call buildTokenWithUid() with a privilege expiry time in seconds (maximum 24 hours per token).
  3. Return the generated token to your client; the client calls agoraEngine.joinChannel(token, channelName, uid, options) — uid and channelName must exactly match the values used to generate the token.
  4. Handle token expiration on the client by listening for the onTokenPrivilegeWillExpire callback (fires 30 seconds before expiry); fetch a fresh token from your server and call agoraEngine.renewToken(newToken) without leaving the channel.
  5. If the token expires before renewal, the SDK fires onConnectionStateChanged with the reason TOKEN_EXPIRED; the client must leave and rejoin with a new token.
  6. For security, never embed your App Certificate in client-side code; always generate tokens server-side and invalidate compromised tokens by rotating the App Certificate in Agora Console (this invalidates all existing tokens).

Known gotchas

Related routes

Create a call server-side with the Stream (getstream.io) Video API and issue a client auth JWT
getstream.io · 5 steps · unrated
Create a Vonage Video API session and generate participant tokens
tokbox.com · 6 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans