Unity Authentication Service in Unreal
Understand how to use Unity Authentication Service with Vivox in Unreal.
Read time 2 minutesLast updated 2 days ago
You can use the Unity Authentication Service (UAS) in your Unreal Vivox application.
Requirements
- Unreal Engine version 5.1.1 or later
- A Unity account
- The Unity Gaming Services SDK for Unreal Engine
Integration steps
- Ensure you have a compatible version of the Unreal Engine for the Unity Gaming Services for Unreal Plugin. Refer to the SDK page in the Unreal Marketplace for more information.
- Go to the Unity Gaming Services SDK for Unreal Engine Unreal Engine Marketplace page in your Epic Games Launcher, or select Open in Launcher from the linked Marketplace page.
- Load the plug-in into your project on the Epic Games Launcher Marketplace page.
- Go into your Project Settings and locate the Unity Authentication plug-in settings.
- Place the Project ID from your Project page on the Unity Dashboard into the Project ID field. The setting will likely autoformat. Place the target environment name in the Environment Name field.
Authenticate with the Unity Authentication Service
Use the following instructions to set up the Unity Authentication Subsystem to sign-in to Vivox:-
Add Authentication to the PublicDependencyModuleName in your project’s build.cs file
- Once you install the plug-in and assign settings in your project, you can set up and une the in C++.
AuthenticationSubsystem
- Once you install the plug-in and assign settings in your project, you can set up and une the
-
Get the UGameInstance from the GameWorld and assign the AuthenticationSubsystem to a variable from the GameInstance.
UWorld* GameWorld = GetWorld();UGameInstance* GameInstance = GameWorld->GetGameInstance();UAuthenticationSubsystem* AuthenticationSubsystem = GameInstance->GetSubsystem<UAuthenticationSubsystem>();
-
Set up an UFunction, named
AuthenticationResponsein the following example, to track when the Authentication has finished successfully. Then, pass it into SignInAnonymously, along with anyOnAuthenticationyou need.FAuthenticationSignInOptionsUnity::Services::Core::THandler<FAuthenticationResponse> authenticationResponse;FName OnAuthenticationFName("OnAuthentication");authenticationResponse.BindUFunction(this, OnAuthenticationFName);FAuthenticationSignInOptions signInOptions;AuthenticationSubsystem->SignInAnonymously(signInOptions, authenticationResponse); -
After Authentication has successfully authenticated to the UGS Service, replace the LoginToken in any call with the AuthenticationSubsystem->GetAccessToken(). Below is an example:
LoginSession.BeginLoginLoginSession.BeginLogin(WebService, AuthenticationSubsystem->GetAccessToken(), SubscriptionMode::Accept, TSet<AccountId>(), TSet<AccountId>(), TSet<AccountId>(), OnBeginLoginCompleteCallback);//This is being done in OnAuthentication, using the returned FAuthenticationResponse as responseAccountId m_Account = AccountId(m_tokenIssuer, response.UserId, m_domain)
ChannelSessionChannelSession.BeginConnect(true, false, true, AuthenticationSubsystem->GetAccessToken(), OnBeginConnectCompleteCallback);