There are three potential primary causes for a
- The token was generated but it was not used before the expiration time. Tokens must be consumed immediately, so the best practice is to only vend tokens when you are ready to use them.
- Inaccurate tokens have been vended. This can happen if the device vending the access tokens has its time set incorrectly; this is usually your game server in production, but might be the game client device when you are evaluating or developing.
For example, if it is 10:15 UTC and your device says it is 10:17 UTC, it could cause a token to expire sooner than expected. Unix time is already standardized to account for time zone differences and daylight saving time, so these do not cause issues. A common way to ensure that your device’s time is accurate is to turn on syncing with a time server.
- The token expiration value has been set incorrectly when creating the access token. The best practice is to set the expiration time to a fixed number of seconds past the current time. In production, it is recommended that you create access tokens with a 90 second expiration (for an example of time calculation for expiration, see the following section).
Important: A token that has already been used returns
(20121) rather than
VxAccessTokenAlreadyUsed (20120) after it has passed its expiration time.
The following examples show a 90 second expiration time for each engine:
time(0L) + 90
Note: Because Vivox Web calculates the time out, you only have to provide the expiration timeout in seconds.