インターフェース実装ベースのトークン生成
How to generate access tokens using an interface implementation.
読み終わるまでの所要時間 1 分最終更新 23日前
Vivox アクセストークン (VAT) が生成される方法を制御する必要がある場合は、Vivox SDK の
IVivoxTokenProviderVivoxService.Instance.SetTokenProviderIVivoxTokenProvider.GetTokenAsyncIVivoxTokenProvider.GetTokenAsyncIVivoxTokenProvider.GetTokenAsyncサブスクライブするには
ユーザーをログインさせる前に、以下を使用してIVivoxTokenProviderVivoxService.Instance.SetTokenProvider(new CustomTokenProvider());
トークンをフェッチする
オーバーライドされたメソッドで提供されているすべてのパラメーター (一部は空の場合あり) を使用してペイロードを作成し、安全なサーバーに送信して、Vivox アクセストークンを作成します。すべてのパラメーターを送信することをお勧めします。ペイロードで必要なもののみが返されます。そのペイロードをGetTokenAsync特定のフローの詳細については、Vivox アクセストークンを使用してサインインする を参照してください サーバー側トークンの生成の詳細については、安全なサーバー上でのトークンの生成 を参照してください。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 }}