Class Authentication subsystem

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
NameDescription
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
NameTypeDescription
OptionsFAuthenticationSignInOptionsOptions for sign-in.
ResponseHandlerTHandler<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
NameTypeDescription
ResponseHandlerTHandler<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
NameTypeDescription
ResponseHandlerTHandler<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
NameTypeDescription
ResponseHandlerTHandler<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
NameTypeDescription
bClearCredentialsboolOption 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 NameParameter TypeDescription
ProfileNameFStringThe 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
NameTypeDescription
ProfileNameFStringThe name of the profile to check.
Returns
TypeDescription
boolTrue if the profile exists, false if it does not.

GetCurrentProfileName()

Returns the name of the current profile.

Declaration
const FString GetCurrentProfileName() const
Returns
TypeDescription
FStringThe name of the current profile.

GetProfileNames()

Returns all active player profile names.

Declaration
const TArray<FString> GetProfileNames() const
Returns
TypeDescription
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
NameTypeDescription
ResponseHandlerTHandler<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
NameTypeDescription
ResponseHandlerTHandler<FAuthenticationPlayerProfileDeletedResponse>Handler that executes upon a player profile getting deleted.

IsSignedIn()

Checks whether the user is signed in or not.

A user can remain signed in but have an expired session.

Declaration
bool IsSignedIn() const
Returns
TypeDescription
boolTrue if user is signed in, else false.

IsAnonymous()

Checks whether the user is signed in anonymously.

Declaration
bool IsAnonymous() const
Returns
TypeDescription
boolTrue if user is signed in anonymously, else false.

IsAuthorized()

Checks whether the user is still authorized.

A user is authorized as long as his access token remains valid.

Declaration
bool IsAuthorized() const
Returns
TypeDescription
boolTrue if user is authorized, else false.

IsExpired()

Checks whether the user session is expired.

Declaration
bool IsExpired() const
Returns
TypeDescription
boolTrue 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
TypeDescription
boolTrue if there is an existing session token stored for the current profile.

GetUnityProjectId()

Returns the Unity project Id.

Declaration
const FGuid GetUnityProjectId() const
Returns
TypeDescription
FGuidThe Unity project Id.

GetUnityEnvironmentName()

Returns the Unity environment name.

Declaration
const FString GetUnityEnvironmentName() const
Returns
TypeDescription
FStringThe Unity environment name.

GetAccessToken()

Returns the current user's access token.

Declaration
FString GetAccessToken() const
Returns
TypeDescription
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
TypeDescription
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
TypeDescription
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
TypeDescription
EAuthenticationStatesThe current state of the authentication subsystem.

SetUnityProjectId(FGuid)

Sets the Unity Project Id.

Declaration
void SetUnityProjectId(FGuid Value)
Parameters
NameTypeDescription
ValueFGuidThe new Unity Project Id.

SetUnityEnvironmentName(FString)

Sets the Unity Environment name.

Declaration
void SetUnityEnvironmentName(FString Value)
Parameters
NameTypeDescription
ValueFStringThe new Unity Environment Id.