> For the complete documentation index, see [llms.txt](https://dynamicpixels.gitbook.io/dynamicpixels-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dynamicpixels.gitbook.io/dynamicpixels-docs/unity-sdk/users-devices.md).

# Users

Explore the list of API functions available in Unity for managing users, including detailed descriptions and usage examples.

{% hint style="warning" %}
To use service functions, first ensure that the service is activated before. You can see services by opening "Service Hub" From the game's dashboard header.&#x20;
{% endhint %}

## Authentication <a href="#login-with-email" id="login-with-email"></a>

### Login with email <a href="#login-with-email" id="login-with-email"></a>

This function will login a player with a pair of email and password, and return the token as result.

```csharp
ServiceHub.Authentication.LoginWithEmail(LoginWithEmailParams input);
```

### Register with email <a href="#register-with-email" id="register-with-email"></a>

This function will register a new user and then login him in and return the token.

```csharp
ServiceHub.Authentication.RegisterWithEmail(RegisterWithEmailParams input);
```

### Login with Google <a href="#login-with-google" id="login-with-google"></a>

With this function, you can log in user with Google Auth.

```csharp
ServiceHub.Authentication.LoginWithGoogle(LoginWithGoogleParams input);
```

### Login as guest <a href="#login-as-guest" id="login-as-guest"></a>

If you want to login users easily and don't show any form, guest login is for you! This function will login users with a unique id and mark the user as a guest. also, you can edit the user and add additional information in the future.

```csharp
ServiceHub.Authentication.LoginAsGuest(LoginAsGuestParams input);
```

### Login with token <a href="#login-with-token" id="login-with-token"></a>

When you login with any function, a token will return that will be used in requests to the server to identify the user. you should save this token in a safe place and load it on every game startup. to prevent login in every game session, you should call this function and pass the saved token.

```csharp
ServiceHub.Authentication.LoginWithToken(LoginWithTokenParams input);
```

### Check OTA is ready <a href="#check-ota-is-ready" id="check-ota-is-ready"></a>

Check if OTA is available and developer can use it. you can fall back to other login ways if it's not available.

```csharp
ServiceHub.Authentication.IsOtaReady(new IsOtaReadyParams());
```

### Send OTA token <a href="#send-ota-token" id="send-ota-token"></a>

If OTA is ready, this function will generate a random key and send it as SMS to specified phone number. this key is valid for few minutes to verify.

```csharp
ServiceHub.Authentication.SendOtaToken(SendOtaTokenParams input);
```

### Verify OTA token <a href="#verify-ota-token" id="verify-ota-token"></a>

After sending OTA key, you should get it by a form and verify it with this function. after that, login process will be done.

```csharp
ServiceHub.Authentication.VerifyOtaToken(VerifyOtaTokenParams input);
```

### Is logged in[​](https://docs.dynamicpixels.dev/users-and-devices/auth-plugin#is-logged-in) <a href="#is-logged-in" id="is-logged-in"></a>

This function return status of user athenticating.

```csharp
ServiceHub.Authentication.IsLoggenIn();
```

### Logout <a href="#logout" id="logout"></a>

This function closes all connections and forgets the user's token. then you can login another user.

```csharp
ServiceHub.Authentication.Logout();
```

## User Management

### Find Users[​](https://docs.dynamicpixels.dev/users-and-devices/users-plugin#find-users) <a href="#find-users" id="find-users"></a>

This function helps you to find other users of the game, and then use their info in other functions.

```csharp
ServiceHub.Services.Users.Find(new FindUserParams());
```

### Get Current User's Info <a href="#get-current-users-info" id="get-current-users-info"></a>

This function return profile information of the current user

```csharp
ServiceHub.Services.Users.GetCurrentUser()
```

### Edit Current User Info[​](https://docs.dynamicpixels.dev/users-and-devices/users-plugin#edit-current-user-info) <a href="#edit-current-user-info" id="edit-current-user-info"></a>

You can edit your current user profile with this function.

```csharp
ServiceHub.Services.Users.EditUserById(new EditUserByIdParams())
```

### Get User Info By Id[​](https://docs.dynamicpixels.dev/users-and-devices/users-plugin#get-user-info-by-id) <a href="#get-user-info-by-id" id="get-user-info-by-id"></a>

With this function, you can get the profile information of a specific user with his id

```csharp
ServiceHub.Services.Users.FindUserById(new FindUserByIdParams())
```

## Device Management

### Get Users Devices[​](https://docs.dynamicpixels.dev/users-and-devices/devices-plugin#get-users-devices) <a href="#get-users-devices" id="get-users-devices"></a>

This function will return the active devices of the current user.

```csharp
var devices = await ServiceHub.Services.Devices.FindMyDevices(new FindMyDeviceParams());
```

### Revoke Device Access[​](https://docs.dynamicpixels.dev/users-and-devices/devices-plugin#revoke-device-access) <a href="#revoke-device-access" id="revoke-device-access"></a>

This function removes access of a specific device and forces it log in again.

```csharp
await ServiceHub.Services.Devices.RevokeDevice(new RevokeDeviceParams
{
    DeviceId = 0
});
```

This function disables access to the revoked device and forces it to log in again.
