# Authentication
For connecting to the server we have some options to use, such as DeviceId and Email which you can use them. We have the plan to add Google and Facebook and other authentication to the project in the future
# Device
DeviceId is an easy way to create a user account. You just need to get the device id and send it to the server. If that device id did not exist in the server, the server creates a new user and send you the result.The id must be unique
var deviceId = SystemInfo.deviceUniqueIdentifier;
client.AuthenticateDeviceId(deviceId, (user, result) =>{
Debug.Log($"({result.Type}) ({result.Message}) ({result.Code}) ");
});
WARNING
It's better to use email instead of deviceId because the device id may change and the user lost its entire data
To create an account by email you need to ask the user for email and password. Password is hashed and then saved in the database, and it must have at least 8 character
client.AuthenticateEmail("user1@hicore.com", "12345678", (user, result) =>{
Debug.Log($"({result.Type}) ({result.Message}) ({result.Code}) ");
});
# Callbacks
After you registered or logged in you get some info from the server that includes user information and the auth result.
# Auth Result
| Field | Description |
|---|---|
| result.Type | the type of result include success,error,warning |
| result.Message | result message |
| result.Code | include type code number |
# User Information
| Field | Description |
|---|---|
| user.UserId | The unique id for the user |
| user.Username | The unique username for the user. |
| user.FriendList | User friend list |
| user.FriendRequest | User friend request list |
| user.TotalFriendRequest | Total number of friend requests |