文档

​
​

Development

User Acquisition

Monetization

工业

Vivox Core SDK

Vivox Core SDK

此页面不支持所选语言。
Vivox
​
​
Vivox Core SDK
  • Overview
  • Before you begin
  • Get started
  • Release notes
  • Developer Guide
  • Reference
  • Privacy overview
  1. Vivox Core SDK documentation

Interface implementation-based token generation

Learn about interface implementation-based token generation.
阅读时间2 分钟
最后更新于 8 个月前

If you want 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.
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 initializing the Vivox SDK, you must register your
IVivoxTokenProvider
implementation using:
VivoxService.Instance.SetTokenProvider(new CustomTokenProvider());

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 }}
To learn more about generating server-side tokens, refer to Generate a token on a secure server.

Copyright © 2026 Unity Technologies
法律信息隐私政策CookiesDocumentation Terms of Use请勿出售或分享我的个人信息您的隐私选择(Cookie 设置)

“Unity”、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属公司在美国和其他地方的商标或注册商标(此处查看更多信息)。其他名称或品牌是其各自所有者的商标。

为方便起见,一些页面是机器翻译的,可能包含不准确的内容。如有信息不一致的情况,以英文版本为准。

  • 在本页上
    • To subscribe

    • Fetch the token


报告此页面的问题