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

Technical Details

Both Login() and Registration() methods perform an authorization call to the UniREST Server application before to proceed with the user login or registration. This special call has the task of verifying that the communication request comes from a Unity project and not from other applications and that the exchange of data through encryption and decryption is working correctly. Basically, this is the operation:

  1. the UniREST Client calls the UniREST Server;
  2. the UniREST Server replies with an encrypted message;
  3. the UniREST Client decrypts the message, modifies it and sends it back encrypted to the UniREST Server;
  4. the UniREST Server decrypts this last message and checks if it has been modified as expected and if this message has been received within 30 seconds;
  5. if everything is ok, the UniREST Server replies with a confirmation and the UniREST Client is authorized to communicate.

If something goes wrong and the authorization fails, the Login() and Registration() methods return false. However, the kind of error is tracked by a specific code available in this UniRESTClient class string property:

UniRESTClient.ServerError;

The ServerError property can have the following codes:

MethodError codeDescription
Login()
Registration()
NO_AUTHThe UniREST Server application has refused the communication request.
Login()
Registration()
NO_COMMUNICATIONThe UniREST Server application is not reachable or properly installed.
Login()NO_ACCOUNTThe provided username and/or password are wrong or an account with that credentials doesn’t exist.
Login()NO_TOKENSThe authorization Tokens are corrupted. This error shouldn’t happen and something in the server-side is not working.
Registration()INVALIDThe account already exists or the username and password strings don’t respect the Database limits.
if (UniRESTClient.ServerError == "NO_AUTH") 
{
  Debug.Log("ERROR: you are not authorized to access to the Database.");
}
else
{
  Debug.Log("OK: you can access to the Database!");
}