Authorization¶
Balancy's authentication methods are subject to updates to enhance versatility and, for certain platforms, processes may be automated for convenience.
Understanding Authentication¶
Balancy initializes with automatic user authentication via the device's unique ID, associating it with a guest account. This mechanism ensures persistent user progress, even across reinstallations, provided the device ID remains consistent.
Users have the option for further authentication methods, such as email or social media platforms, typically managed through FireBase. Post-authentication, these accounts can synchronize with Balancy using Balancy.Auth.WithName
.
Authentication Scenarios:¶
-
Switching Accounts: To transition between Balancy accounts, follow these steps:
- Sign out from the current Balancy session.
- Utilize
Balancy.Auth.WithName
for re-authentication.
-
Linking New Authentication Method: Invoking
Balancy.Auth.WithName
can link a new authentication method. However, outcomes vary:- Should Balancy recognize it as a new authentication, the link is immediate.
- If another user is already linked to this authentication, a conflict arises. You must then choose between the local profile or the one on Balancy's servers. Selection dictates whether the new method replaces the current link or if the local account updates to match the server's data.
Authorization Methods:¶
Name and Password¶
Balancy.Auth.WithName(<username>, <password>, authResponse =>
{
Debug.Log("Authorized " + authResponse.Success);
if (authResponse.Success)
Debug.Log("User id: " + authResponse.UserId);
});
As a Guest using the Device ID¶
Balancy.Auth.AsGuest(authResponse =>
{
Debug.Log("Authorized " + authResponse.Success);
if (authResponse.Success)
Debug.Log("User id: " + authResponse.UserId);
});
Additional methods¶
var balancyUserId = Balancy.Auth.GetUserId();
var isAuthorized = Balancy.Auth.IsAuthorized();
Balancy.Auth.SignOut(<game_id>, <environment>, () => {
Debug.Log("Signed Out");
});