Skip to content

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:

  1. Switching Accounts: To transition between Balancy accounts, follow these steps:

    1. Sign out from the current Balancy session.
    2. Utilize Balancy.Auth.WithName for re-authentication.
  2. Linking New Authentication Method: Invoking Balancy.Auth.WithName can link a new authentication method. However, outcomes vary:

    1. Should Balancy recognize it as a new authentication, the link is immediate.
    2. 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");
});