> 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/users.md).

# Users

Explore the list of API functions available in TypeScript 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 log in a player with a pair of email and password, and return the token as the result.

```typescript
DynamicPixels.Auth.LoginWithEmail(input: LoginWithEmailParams): Promise<LoginResponse>;
```

### 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.

```typescript
DynamicPixels.Auth.RegisterWithEmail(input: RegisterWithEmailParams): Promise<LoginResponse>;
```

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

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

```typescript
DynamicPixels.Auth.LoginWithGoogle(input: LoginWithGoogleParams): Promise<LoginResponse>;
```

### 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.

```typescript
DynamicPixels.Auth.LoginAsGuest(input: LoginAsGuestParams): Promise<LoginResponse>;
```

### 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.

```typescript
DynamicPixels.Auth.LoginWithToken(input: LoginWithTokenParams): Promise<LoginResponse>;
```

### 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.

```typescript
DynamicPixels.Auth.IsOtaReady(input: IsOtaReadyParams): Promise<boolean>;
```

### 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 an SMS to a specified phone number. this key is valid for a few minutes to verify.

```typescript
DynamicPixels.Auth.SendOtaToken(input: SendOtaTokenParams): Promise<boolean>;
```

### 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.

```typescript
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 returns the status of the user authentication.

```typescript
DynamicPixels.Auth.IsLoggedIn():boolean
```

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

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

```typescript
DynamicPixels.Auth.Logout():void
```

## 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.

```typescript
DynamicPixels.Services.Users.FindUsers<T extends FindUsersParams>(input: T): Promise<User[]>
```

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

This function returnsthe  profile information of the current user

```typescript
DynamicPixels.Services.Users.GetCurrentUser(): Promise<User>
```

### 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.

```typescript
DynamicPixels.Services.Users.EditCurrentUser<T extends EditCurrentUserParams>(input: T): Promise<User>
```

### 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

```typescript
DynamicPixels.Services.Users.GetUserById<T extends GetUserByIdParams>(input: T): Promise<User>
```

## 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.

```typescript
DynamicPixels.Services.Devices.GetMyDevices(): Promise<Device[]>;
```

### 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 to a specific device and forces it login again.

```typescript
DynamicPixels.Services.Devices.RevokeDevice<T extends RevokeDeviceParams>(input: T): Promise<void>;
```

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