1. Home
  2. Docs
  3. UniREST Solution 3.5
  4. UniREST Client
  5. Login and Registration
  6. ApplicationLogin

ApplicationLogin

The ApplicationLogin() method simply registers your Unity Game or Application and automatically performs the login.

This method is useful if you do not need each player to have their own account, but only need your Game to have access to your Server to manage data related to the Game.

Simply place the UniRESTClient.ApplicationLogin() call where your Game starts.

_ = UniRESTClient.Async.ApplicationLogin(onComplete);
onCompleteAction<bool>The function to call when the operation is completed.
It must have a boolean parameter. It will be true if everything worked, false otherwise.
booltrue if everything worked, false otherwise.
- = UniRESTClient.Async.ApplicationLogin((bool ok) => 
    {
        if (ok) 
        {
            // Unity project logged in!
        }
        else
        {
            // Login failed.
            // ...
        }
    });

How it works

When you use the ApplicationLogin() method, the UniREST system registers your Game as if it was a single player. Basically, UniREST creates a new account with a fixed username and password and use it for logging-in. Because it is a fixed account, all the players that will use your Game will log in with the same account.

The account credentials are generated using part of the system security Keys, so it’s very important that you don’t alter the Configuration keys.

The working flow is pretty simple:

  1. the Game try to perform a Login using the fixed Game account;
  2. if the Login fails, the Game assumes that this fixed account doesn’t exist. So, the Game register this new fixed account;
  3. now that this account has been registered, the Game performs the login.