Documentation

Support

Authentication for Unreal Engine

Authentication overview

Authentication for Unreal Engine

Class Authentication subsystem

Reference the Authentication Subsystem class for handling connections to Unity Authentication.
Read time 5 minutesLast updated 2 hours ago

Subsystem for handling connections to the Unity Authentication system.
Include
#include "AuthenticationSubsystem.h"
Syntax
UCLASS()class AUTHENTICATION_API UAuthenticationSubsystem : public UGameInstanceSubsystem

Constructors

UAuthenticationSubsystem()

Default constructor for the Authentication subsystem.

Declaration

UAuthenticationSubsystem()

UAuthenticationSubsystem(FVTableHelper&)

Override constructor for forward declaration.

Declaration

UAuthenticationSubsystem(FVTableHelper& Helper)

Parameters

Name

Description

HelperHelper class to invoke specialized hot-reload constructor.

Destructors

UAuthenticationSubsystem()

Default destructor for the Authentication subsystem.

Declaration

virtual ~UAuthenticationSubsystem()

Overrides

Initialize(FSubsystemCollectionBase&)

Initialize overrides from USubsystem.

Declaration

virtual void Initialize(FSubsystemCollectionBase& Collection) override

Deinitialize()

Initialize overrides from USubsystem.

Declaration

virtual void Deinitialize() override

ShouldCreateSubsystem(UObject*)

Initialize overrides from USubsystem.

Declaration

virtual bool ShouldCreateSubsystem(UObject* Outer) const override

Methods

SignInAnonymously(FAuthenticationSignInOptions, Unity::Services::Core::THandler<FAuthenticationResponse>)

Signs in the current user anonymously. No credentials are required and the session is confined to the current device.

Declaration

void SignInAnonymously(FAuthenticationSignInOptions Options, Unity::Services::Core::THandler<FAuthenticationResponse> ResponseHandler)

Parameters

Name

Type

Description

Options
FAuthenticationSignInOptionsOptions for sign-in.
ResponseHandler
THandler
<
FAuthenticationResponse
>
Handler that executes when the API has returned a response.

GetUserInfo(Unity::Services::Core::THandler<FAuthenticationUserResponse>)

Returns the current player's player info, such as account creation time and linked external ids.

Declaration

void GetUserInfo(Unity::Services::Core::THandler<FAuthenticationUserResponse> ResponseHandler)

Parameters

Name

Type

Description

ResponseHandler
THandler
<
FAuthenticationUserResponse
>
Handler that executes when the API has returned a response.

DeleteUser(Unity::Services::Core::THandler<bool>)

Deletes the currently signed in user permanently.

Declaration

void DeleteUser(Unity::Services::Core::THandler<bool> ResponseHandler)

Parameters

Name

Type

Description

ResponseHandler
THandler
<bool>
Handler that executes when the API has returned a response.

RegisterStateChangedCallback(Unity::Services::Core::THandler<FAuthenticationStateChangedResponse>)

Hooks into a delegate that executes upon the authentication state changing.

Declaration

void RegisterStateChangedCallback(Unity::Services::Core::THandler<FAuthenticationStateChangedResponse> ResponseHandler)

Parameters

Name

Type

Description

ResponseHandler
THandler
<
FAuthenticationStateChangedResponse
>
Handler that executes upon the authentication state changing.

SignOut(bool)

Signs-out the current user under the provided profile name.

Declaration

bool SignOut(bool bClearCredentials = false)

Parameters

Name

Type

Description

bClearCredentials
bool
Option to clear the session token that enables logging in to the same account.

SwitchProfile(const FString&)

Switches the current profile to a new profile name. If a profile was not found under that name, a new one is created.

Declaration

void SwitchProfile(const FString& ProfileName) const

Parameters

Parameter Name

Parameter Type

Description

ProfileName
FStringThe name of the profile to switch to, or add if it does not yet exist.

ProfileExists(const FString&)

Check if a profile exists.

Declaration

const bool ProfileExists(const FString& ProfileName) const

Parameters

Name

Type

Description

ProfileName
FStringThe name of the profile to check.

Returns

Type

Description

bool
True if the profile exists, false if it does not.

GetCurrentProfileName()

Returns the name of the current profile.

Declaration

const FString GetCurrentProfileName() const

Returns

Type

Description

FStringThe name of the current profile.

GetProfileNames()

Returns all active player profile names.

Declaration

const TArray<FString> GetProfileNames() const

Returns

Type

Description

TArray<FString>All the active player profile names.

RegisterProfileChangedCallback(Unity::Services::Core::THandler<FAuthenticationPlayerProfileChangedResponse>)

Hooks into a Handler that executes upon the player profile changing.

Declaration

void RegisterProfileChangedCallback(Unity::Services::Core::THandler<FAuthenticationPlayerProfileChangedResponse> ResponseHandler)

Parameters

Name

Type

Description

ResponseHandler
THandler
<
FAuthenticationPlayerProfileChangedResponse
>
Handler that executes upon the player profile changing.

RegisterProfileDeletedCallback(Unity::Services::Core::THandler<FAuthenticationPlayerProfileDeletedResponse> ResponseHandler)

Hooks into a Handler that executes upon a player profile getting deleted.

Declaration

void RegisterProfileDeletedCallback(Unity::Services::Core::THandler<FAuthenticationPlayerProfileDeletedResponse> ResponseHandler)

Parameters

Name

Type

Description

ResponseHandler
THandler
<
FAuthenticationPlayerProfileDeletedResponse
>
Handler that executes upon a player profile getting deleted.

IsSignedIn()

Checks whether the user is signed in or not.

Declaration

bool IsSignedIn() const

Returns

Type

Description

bool
True if user is signed in, else false.

IsAnonymous()

Checks whether the user is signed in anonymously.

Declaration

bool IsAnonymous() const

Returns

Type

Description

bool
True if user is signed in anonymously, else false.

IsAuthorized()

Checks whether the user is still authorized.

Declaration

bool IsAuthorized() const

Returns

Type

Description

bool
True if user is authorized, else false.

IsExpired()

Checks whether the user session is expired.

Declaration

bool IsExpired() const

Returns

Type

Description

bool
True if user's session expired, else false.

SessionTokenExists()

Checks if there is an existing session token stored for the current profile.

Declaration

bool SessionTokenExists() const

Returns

Type

Description

bool
True if there is an existing session token stored for the current profile.

GetUnityProjectId()

Returns the Unity project Id.

Declaration

const FGuid GetUnityProjectId() const

Returns

Type

Description

FGuidThe Unity project Id.

GetUnityEnvironmentName()

Returns the Unity environment name.

Declaration

const FString GetUnityEnvironmentName() const

Returns

Type

Description

FStringThe Unity environment name.

GetAccessToken()

Returns the current user's access token.

Declaration

FString GetAccessToken() const

Returns

Type

Description

FStringA string of current user's access token when they are signed in, otherwise an empty string.

GetSessionToken()

Returns the current user's session token.

Declaration

const const FString GetSessionToken() const

Returns

Type

Description

FStringA string of current user's session token when they are signed in, otherwise an empty string.

GetUserId()

The current user's Id when they are signed in.

Declaration

const FString GetUserId() const

Returns

Type

Description

FStringThe current user's Id when they are signed in, otherwise an empty string.

GetState()

The current state of the authentication subsystem.

Declaration

const EAuthenticationStates GetState() const

Returns

Type

Description

EAuthenticationStatesThe current state of the authentication subsystem.

SetUnityProjectId(FGuid)

Sets the Unity Project Id.

Declaration

void SetUnityProjectId(FGuid Value)

Parameters

Name

Type

Description

ValueFGuidThe new Unity Project Id.

SetUnityEnvironmentName(FString)

Sets the Unity Environment name.

Declaration

void SetUnityEnvironmentName(FString Value)

Parameters

Name

Type

Description

ValueFStringThe new Unity Environment Id.