文档

​
​

Development

User Acquisition

Monetization

工业

Vivox Core SDK

Vivox Core SDK

此页面不支持所选语言。
Vivox
​
​
Vivox Core SDK
  • Overview
  • Before you begin
  • Get started
    • Integration guide
    • Quick start guide
      • Initializing Vivox
      • Logging in
      • Assign a unique username
      • Generate a login access token
      • Submit a login request
      • Joining and leaving channels
      • Generate and submit a join token
      • Process join responses and events
      • Handle join errors
  • Release notes
  • Developer Guide
  • Reference
  • Privacy overview
  1. Vivox Core SDK documentation

Generate a login access token

How to form a login token on a game server.
阅读时间3 分钟
最后更新于 8 个月前

The next step in the login process is to correctly form a login token on a game server. This step is important to understand as it contributes to a significant number of Vivox integration mistakes. Here are some key facts to understand Login Tokens in general:
  • Login tokens can only be used once.
  • Expiration timers are important; leave room for unforeseen circumstances such as slow internet connections or inactive instances.
    • Current best practice for expiration time is Time.Now + 90 seconds.
  • Your game will provide its own account names and login tokens.
  • There are three key sections to the login tokens:
    • Header
    • Payload
    • Signature

Login token - Header

In the case of Vivox, the header is empty to satisfy the JSON Web Token (JWT) standards. The header can be formed either as code or as a constant.

Code

Constant

base64URLencode(“{}”)An empty header should always resolve to “e30” when encoded, this can be stored as a constant in your code if it fits your needs.

Login token - Payload

Crafting a payload consists of a defined set of claims you make to the Vivox server. Your code can craft an object to store these claims. The claims apply to tokens other than login tokens, so they can be serialized and encoded when you submit your request to Vivox.

Explanation

Example claims object

N/Apublic class Claims {
Issuerpublic string iss {get;set;}
Expiration time in “epoch seconds”public int exp {get;set;}
Vivox Actionpublic string vxa {get;set;}
VXI is a claim that guarantees uniqueness, a simple incremented integer can be used.public int vxi {get;set;}
Full details on who the token is “from”public string f {get;set;}
Not used for login tokens.public string t {get;set;}
N/Apublic string sub {get;set;} }

Example login token

Claims loginClaim = new Claims{iss=issuer-ba63,vxi = 93000,vxa:login,exp=1600349400,f=sip:.issuer-ba63.030104_16.@tla.vivox.com };

Some best practices for token payloads

  • All information should be base64URLEncoded, this is different from base64encode.
  • Current best practice for expiration time is Time.Now + 90 seconds.
  • VXI is a claim that guarantees uniqueness, a simple incremented integer can be used.

Login token - Signature

The signature combines the header and payload into a signed hash-based message authentication code (HMAC) which is then encoded. This is where the key provided by Vivox is used to protect your service and authenticate your communication.
To form this HMAC:
  1. Join your encoded header and encoded payload together with a period.
  2. Process the result through an HMACSHA256 process.
  3. Use the “secret” provided in your Vivox Developer Portal credentials as the signing key in the HMAC process/method.
A pseudo-code example of this can be found on the Access token signature page.
Your final result should resemble this example:
e30.eyJpc3MiOiJibGluZG1lbG9uLUFwcE5hbWUtZGV2IiwidnhhIjoibG9naW4iLCJ2eGkiOjkzMzAwMCwiZXhwIjoxNjAwMzQ5NDAwLCJmIjoic2lwOi5ibGluZG1lbG9uLUFwcE5hbWUtZGV2Lmplcmt5LkB0bGEudml2b3guY29tIn0.5FKsAQz7bRQGGlSZw-KIcCmft7Ic6nT3Ih-TbdYPWwI
Color guide:
HeaderPayloadSignature
The next step is to submit your login request using the login token.

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

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

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

  • 在本页上
    • Login token - Header

    • Login token - Payload

      • Example login token

      • Some best practices for token payloads

    • Login token - Signature


报告此页面的问题