Authorization

AuthService

All actions and storage of authorization data are controlled by this class.

  • Obtaining all necessary authorization data
string playerID = AuthService.PlayerID;
string email = AuthService.SavedEmail;
. . .

PlayerID (string) – user identifier.

LastAuthType (enum) – The last way the user logged in.

IsLoggedIn (bool) – whether the user is logged in not in guest mode.

AuthContext (class) – authorization context contains all information about authorization, user ID, project ID, session ID, etc. It is mainly used to authorize a user on the server.

SavedEmail and SavedPassword (string) – if the user is logged in via email. mail, then these fields contain information about the email. mail and password.

  • Subscribe to an event

*You should subscribe to events in “OnEnable” and unsubscribe in “OnDisable” methods.

AuthService.LoggedIn += OnLoggedIn;
AuthService.RequestSent += OnSentRequest;

LoggedIn – The user is logged in by any available method.
RequestSent – a request for authorization has been sent using any available method.

  • Methods
AuthService.Instance.LoginWithDeviceID();

. . .

In almost all methods, you can additionally specify the “OnSuccess, OnError, OnNetworkError” methods as arguments.

AuthService.Instance.LoginWithDeviceID(OnSuccess, OnError, OnNetworkError);

private void OnSuccess(LoginResult result)
{
	// Some logic
}

private void OnError(PlayFabError error)
{
	// Some logic
}

private void OnNetworkError()
{
	// Some logic
}

LoginWithDeviceID – log in using the device ID.

LogOut – Log out if you are not logged in as a guest (email, etc.). The user is then automatically logged into the system in guest mode.

LoginWithEmailAddress – login with email and password.

AddUsernamePassword – add an email to an existing user.

SendAccountRecoveryEmail – send an email to password reset address.

DeleteTitlePlayerAccount – delete the player’s account, after deletion the user is automatically logged into the system in guest mode.

  • AutoLogin

To automatically login, drop the “AutoLogin” prefab on the first scene (iDosGamesSDK -> Prefabs -> Authorization)

Powered by BetterDocs

Go to Top