---
title: "Users client"
slug: "users-client-1523458"
abstract: ""
---
# Users client

The SDK provides a **Users client** to fetch users and user groups by name and also features some password management operations.

> [!note]
> The `client` variable in the following code examples refers to the `ContentHubClient` instance. When using the JavaScript SDK, the variable name can be chosen freely, but is also called `client` at instantiation in the documentation.

Users and user groups are entities that can be used with the **Querying client** and the **Entities client**.

## Getting users

The `getUserAsync` method gets a user by username. The following example fetches the user entity of by username:

```javascript
import { IEntity } from "@sitecore/sc-contenthub-webclient-sdk/dist/contracts/base/entity";
import { EntityLoadConfiguration } from "@sitecore/sc-contenthub-webclient-sdk/dist/contracts/querying/entity-load-configuration";

var loadConfig = new EntityLoadConfiguration();
var user: IEntity = await client.users.getUserAsync("username", loadConfig);

```

## Getting user groups

The `getUserGroupAsync` method gets a user group by name. The following example fetches the user group entity by name:

```javascript
import { IEntity } from "@sitecore/sc-contenthub-webclient-sdk/dist/contracts/base/entity";
import { EntityLoadConfiguration } from "@sitecore/sc-contenthub-webclient-sdk/dist/contracts/querying/entity-load-configuration";

var loadConfig = new EntityLoadConfiguration();
var group: IEntity = await client.users.getUserGroupAsync("groupName", loadConfig);

```

## Setting passwords

Superusers are permitted to set passwords of other users. Use the `setPasswordAsync` method to change the password of a specific user:

```javascript
var userId: number = await client.users.getUserIdAsync("username");
await client.users.setPasswordAsync(userId,"securePassword");

```

The first argument is the ID of the user (e.g. `100`). The second argument is the new password.

## Resetting passwords

Superusers are permitted to send forgotten password e-mails to users. To do this, call the `resetPasswordAsync` method with the ID of the user. An e-mail is sent containing a unique and secure link to a page where the user can change their password.

```javascript
var userId: number = await client.users.getUserIdAsync("username");
await client.users.resetPasswordAsync(userId);

```

> [!note]
> This feature only affects users created and managed in Sitecore Content Hub. It should not be used on users that were created and managed by a single sign-on (SSO) provider.