Generate a token on the client

Important: Use the following access token generation methods during initial development and prototyping. Do not include this method of generation in production builds of your game. Allowing token generation on the client during production is both a security risk and can cause unexpected token expiration errors for your users.

The following APIs are available to generate insecure access tokens from the client for use during early development:

Each API takes the following parameters:

  • The token signing key
  • The token time to live in seconds

The following examples display access tokens for login and join, respectively:

const TCHAR *kKey = TEXT("demo-key");
const FTimespan kExpiration = FTimespan::FromSeconds(90);

// Login (This assumes an already initialized Client object)
ILoginSession &loginSession(client.GetLoginSession(/* Account to login */));
loginSession.GetLoginToken(kKey, kExpiration);

// Join (This assumes an already signed in ILoginSession object)
IChannelSession &channelSession(loginSession.GetChannelSession(/* ChannelId to join*/));
channelSession.GetConnectToken(kKey, kExpiration);

// Mute (This assumes an already signed in ILoginSession object joined to a Connected IChannelSession)
IChannelSession &channelSession(loginSession.GetChannelSession(/* ChannelId to mute in*/));
IParticipant &participant(channelSession.Participants()[ParticipantKey]);
participant.GetMuteForAllToken(kKey, kExpiration);

// Transcription (This assumes an already signed in ILoginSession object joined to a Connected IChannelSession)
IChannelSession &channelSession(loginSession.GetChannelSession(/* ChannelId to begin transcribing*/));
channelSession.GetTranscriptionToken(kKey, kExpiration);