UAS와 함께 Vivox 액세스 토큰 사용
Follow this workflow to use Vivox Access Tokens together with Unity Authentication Services.
읽는 시간 1분최근 업데이트: 14시간 전
어떤 플레이어가 어떤 채널에 액세스할 수 있는지 완전히 제어하려면 자체 백엔드에서 VAT(Vivox 액세스 토큰)를 발급하도록 할 수 있습니다.
필수 조건:
- Unity Cloud 프로젝트 설정
- 프로젝트 ID, 개발 환경 ID, 개발 환경 이름이 있어야 합니다.
- UAS 커스텀 ID 제공자 활성화
- 이 설정에서 서비스 계정 인증정보를 손쉽게 사용할 수 있어야 합니다.

VAT 생성
- Vivox SDK는 커스텀 토큰 제공자 구현을 사용하여 필요할 때마다 백엔드에서 VAT를 요청합니다.
- 메서드 내에서 VAT를 요청할 때 백엔드에 대한 요청에
GetTokenAsync를 추가합니다.accessToken - 백엔드에서 토큰을 확인하고 필요한 정보를 추출한 후 Vivox 액세스 토큰을 생성하여 클라이언트로 반환합니다.
클라이언트 측 설정
게임 클라이언트에서 Vivox SDK의IVivoxTokenProviderVivoxService.Instance.SetTokenProviderIVivoxTokenProvider.GetTokenAsyncIVivoxTokenProvider.GetTokenAsyncIVivoxTokenProvider.GetTokenAsync구독하기
다음과 같이IVivoxTokenProviderVivoxService.Instance.SetTokenProvider(new CustomTokenProvider());
토큰 가져오기
일부가 비어 있더라도 오버라이드된 메서드에 제공된 모든 파라미터를 사용하여 페이로드를 생성하고 이를 보안 서버로 보내 Vivox 액세스 토큰을 생성합니다. 가장 좋은 방법은 모든 파라미터를 보내는 것입니다. 페이로드에 필요한 것만 반환됩니다. 페이로드를GetTokenAsynctargetUserUrichannelUripublic 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) { if (!AuthenticationService.Instance.SessionTokenExists) { // Player not logged in! } var accessToken = AuthenticationService.Instance.AccessToken // Implement token fetching logic here. // The method parameters together with the accessToken from the AuthenticationService contain the necessary information for crafting the request payload. // This will be called whenever a token is needed for a Vivox action }}
서버 측 설정
백엔드 서비스에서는 클라이언트가 위의GetTokenAsyncsip:.issuer.unity_player_id.unity_environment_id.@domain.vivox.com
issuerunity_player_idunity_environment_idGetTokenAsyncaccessTokensubaudaud이를 통해 VAT를 생성하고 클라이언트로 반환할 수 있습니다.{ "header": { "alg": "RS256", "kid": "<id>", "typ": "JWT" }, "payload": { "aud": [ "upid:{{unity_project_id}}", "envName:{{environment_name}}", "envId:{{unity_environment_id}}" // unity environment id ], "exp": 1617677595, // expires at "iat": 1617673872, // issued at "nbf": 1617673872, // not valid before "sub": "{{unity_player_id}}", // UAS player ID "project_id": "{{unity_project_id}}" // unity project id }}