Documentation

​
​

Development

User Acquisition

Monetization

Industry

Vivox Unity SDK

Vivox Unity SDK

Vivox
​
​
Vivox Unity SDK
  • Overview
  • Get started
  • Release notes
  • Developer guide
  • Tutorials
    • Implement Vivox Unity
    • Access Token Developer Guide
      • Access token terminology
      • Requests that require access tokens
      • Access token identifiers
      • Access token format
      • Access token examples
      • Generate a token from the client
        • Authentication-based token generation
        • Interface implementation-based token generation
      • Generate a token on a secure server
      • Key update API
      • Access token error codes
  • Reference
  1. Vivox Unity SDK documentation

Interface implementation-based token generation

How to generate access tokens using an interface implementation.
Read time 2 minutes
Last updated 8 months ago

To control how Vivox Access Tokens (VATs) are generated, create a class that implements the Vivox SDK’s
IVivoxTokenProvider
interface and register it with the VivoxService.
When you register your implementation of IVivoxTokenProvider by calling
VivoxService.Instance.SetTokenProvider
, Vivox will call your implementation's
IVivoxTokenProvider.GetTokenAsync
method whenever a token is needed for actions such as logging in.
Note
A best practice reccomendation for token generation is to use Unity Cloud Code to generate your tokens. For further details on using Cloud Code for token generation, review the token API documentation.
The information needed to create a payload is provided as input to the overridden
IVivoxTokenProvider.GetTokenAsync
method. This information is used when crafting a VAT.
You will still need to set up server-side token vending and fetch the token within the overridden
IVivoxTokenProvider.GetTokenAsync
method.

To subscribe

Before logging in your user, you must register your
IVivoxTokenProvider
implementation using:
VivoxService.Instance.SetTokenProvider(new CustomTokenProvider());
Important
The subscribe flow changed in v16.5.0. For Unity Vivox SDK versions previous to 16.5.0, you must register your
IVivoxTokenProvider
implementation before initializing the Vivox SDK.

Fetch the token

Create the payload with all of the parameters provided in the overridden method, even if some are empty, and send it to your secure server to generate your Vivox Access Token. Best practice is to send all the parameters; only what’s needed for the payload will be returned. Use the payload as input into the
GetTokenAsync
method.
For certain tokens, different parameters will be empty. For example, targetUserUri and channelUri will be empty for a login token. This is expected behaviour.
The following is an example of token generation:
public class VoiceManager : MonoBehaviour{ async void Start() { // Must be done before any other Vivox action otherwise tokens will not be generated properly. VivoxService.Instance.SetTokenProvider(new VivoxTokenProvider()); await UnityServices.InitializeAsync(); await VivoxService.Instance.InitializeAsync(); }}class VivoxTokenProvider : IVivoxTokenProvider{ public Task<string> GetTokenAsync(string issuer = null, TimeSpan? expiration = null, string targetUserUri = null, string action = null, string channelUri = null, string fromUserUri = null, string realm = null) { // Implement token fetching logic here. // The method parameters contain the necessary information for crafting the request payload. // This will be called whenever a token is needed for a Vivox action }}
For more details on this specific flow, refer to Sign in with Vivox Access Token
To learn more about generating server-side tokens, refer to Generate a token on a secure server.

Copyright © 2026 Unity Technologies
LegalPrivacy PolicyCookiesDocumentation Terms of UseDo Not Sell or Share My Personal InformationYour Privacy Choices (Cookie Settings)

"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S and elsewhere (more info here). Other names or brands are trademarks of their respective owners.

Some pages are machine-translated for convenience, and may contain inaccuracies. In the event of conflicting information, the English version is authoritative.

  • On this page
    • To subscribe

    • Fetch the token


Report a problem with this page