# Manage users
Authing management module.
This module can perform operations such as adding, deleting, modifying and querying user directories, searching for users, refreshing user tokens, managing user groups, managing user roles, and managing user policy authorization.
# Create user
UsersManagementClient().create(userInfo)
This interface will create a user as an administrator and does not require security checks such as mobile phone number verification code verification.
# Parameters
userInfo
<CreateUserInput> user informationuserInfo.email
<string> mailbox, the only one in the user pooluserInfo.emailVerified
<boolean> Is the email verified?userInfo.phone
<string> phone numberuserInfo.phoneVerified
<boolean> Whether the phone number is verifieduserInfo.unionid
<string> For users who log in as social, this field is the unique ID of the user in the third-party social login service provideruserInfo.openid
<string> openid returned by WeChat loginuserInfo.password
<string> passworduserInfo.registerSource
<string> Registration source, you can select multipleuserInfo.username
<string> usernameuserInfo.nickname
<string> nicknameuserInfo.photo
<string> AvataruserInfo.company
<string> companyuserInfo.browser
<string> browseruserInfo.loginsCount
<number> Number of logins, this field can be set when you migrate from the original user system to Authing.userInfo.lastLogin
<string> Last login time, a time string conforming to ISO8601 format. (E.g. "2017-06-07T14:34:08.700Z", "2017-06-07T14:34:08.700 or "2017-06-07T14:34:08+04:00")userInfo.lastIP
<string> The IP of the user's last login (or other activity)userInfo.signedUp
<string> Registration time, a time string conforming to ISO8601 format. (E.g. "2017-06-07T14:34:08.700Z", "2017-06-07T14:34:08.700 or "2017-06-07T14:34:08+04:00")userInfo.blocked
<boolean> whether the account is disableduserInfo.isDeleted
<boolean> mark whether the account is deleteduserInfo.device
<string> deviceuserInfo.lastIP
<string> Last logged in IPuserInfo.name
<string> NameuserInfo.givenName
<string> Given NameuserInfo.familyName
<string> Family NameuserInfo.middleName
<string> Middle NameuserInfo.profile
<string> Profile UrluserInfo.preferredUsername
<string> Preferred NameuserInfo.website
<string> personal websiteuserInfo.gender
<string> gender, M stands for male, W stands for female, and U stands for unknown.userInfo.birthdate
<string> birthdayuserInfo.zoneinfo
<string> time zoneuserInfo.locale
<string> languageuserInfo.address
<string> addressuserInfo.streetAddress
<string> street addressuserInfo.locality
<string>userInfo.region
<string> regionuserInfo.postalCode
<string> Zip codeuserInfo.city
<string> cityuserInfo.province
<string> provinceuserInfo.country
<string> countryuserInfo.externalId
<string> external id
# Example
String email = "test@example.com";
String password = "123456";
User user = managementClient.users().create(new CreateUserInput().withEmail(email).withPassword(password)).execute();
# Modify user information
UsersManagementClient *().update(id, updates)
Modify user information
# Parameters
id
<string> User IDupdates
<UpdateUserInput> modified user profileupdates.email
<string> Emailupdates.emailVerified
<boolean> Is the email verified?updates.phone
<string> phone numberupdates.phoneVerified
<boolean> Whether the phone number is verifiedupdates.unionid
<string> For users who log in socially, this field is the user's unique ID in the third-party social login service providerupdates.openid
<string> openid returned by WeChat loginupdates.password
<string> passwordupdates.registerSource
<string> Registration source, you can select multipleupdates.tokenExpiredAt
<string> token expiration time, a time string conforming to the ISO8601 format. (Such as "2017-06-07T14:34:08.700Z", "2017-06-07T14:34:08.700 or "2017-06-07T14:34:08+04:00"). Setting this field to be less than the current time can invalidate the user's token.updates.username
<string> usernameupdates.nickname
<string> nicknameupdates.photo
<string> Avatarupdates.company
<string> companyupdates.browser
<string> browserupdates.loginsCount
<number> Number of logins, this field can be set when you migrate from the original user system to Authing.updates.lastLogin
<string> Last login time, a time string conforming to ISO8601 format. (E.g. "2017-06-07T14:34:08.700Z", "2017-06-07T14:34:08.700 or "2017-06-07T14:34:08+04:00")updates.lastIP
<string> The IP of the user's last login (or other activity)updates.signedUp
<string> Registration time, a time string conforming to ISO8601 format. (E.g. "2017-06-07T14:34:08.700Z", "2017-06-07T14:34:08.700 or "2017-06-07T14:34:08+04:00")updates.blocked
<boolean> whether the account is disabledupdates.device
<string> deviceupdates.lastIP
<string> Last logged in IPupdates.name
<string> Nameupdates.givenName
<string> Given Nameupdates.familyName
<string> Family Nameupdates.middleName
<string> Middle Nameupdates.profile
<string> Profile Urlupdates.preferredUsername
<string> Preferred Nameupdates.website
<string> personal websiteupdates.gender
<string> gender, M stands for male, W stands for female, and U stands for unknown.updates.birthdate
<string> birthdayupdates.zoneinfo
<string> time zoneupdates.locale
<string> languageupdates.address
<string> addressupdates.streetAddress
<string> street addressupdates.locality
<string>updates.region
<string> regionupdates.postalCode
<string> Zip codeupdates.city
<string> cityupdates.province
<string> provinceupdates.country
<string> countryuserInfo.externalId
<string> external id
# Example
# Get user details
UsersManagementClient().detail(userId)
Get user details by user ID. If you want to get user details by token, please use AuthenticationClient SDK.
# Parameters
userId
<string> user ID
# Example
User result = managementClient.users().detail("userId").execute();
# delete users
UsersManagementClient().delete(userId)
Delete user
# Parameters
userId
<string> user ID
# Example
CommonMessage message = managementClient.users().delete("userId").execute();
# Delete users in batch
UsersManagementClient().deleteMany(userIds)
Batch delete users
# Parameters
userIds
<string[]> list of user IDs
# Example
ArrayList<String> userIds = new ArrayList<>();
userIds.add("userId");
CommonMessage message = managementClient.users().deleteMany(userIds).execute();
# Get users in batch
UsersManagementClient().batch(userIds)
Get user details in batches by ID
# Parameters
userIds
<string[]> list of user IDs
# Example
ArrayList<String> userIds = new ArrayList<>();
userIds.add("userId");
List<User> users = managementClient.users().batch(userIds).execute();
# Get user list
UsersManagementClient().list(page, limit)
Get user pool user list
# Parameters
page
<number> Page number, starting from 1 The default value is:1
.limit
<number> The number of users included in each page The default value is10
.
# Example
PaginatedUsers users = managementClient.users().list().execute();
# Check if the user exists
UsersManagementClient().exists(options)
Check whether the user exists. The currently detectable fields are user name, email address, and mobile phone number.
# Parameters
options
<Object>options.username
<string> User name, case sensitive.options.email
<string> mailbox, the mailbox is not case sensitive.options.phone
<string> phone number
# Example
Boolean exists = managementClient.users().exists(new IsUserExistsParam().withUsername("test")).execute();
# Find users
UsersManagementClient().find(options)
Find users by username, email, mobile phone number
# Parameters
options
<Object>options.username
<string> User name, case sensitive.options.email
<string> mailbox, the mailbox is not case sensitive.options.phone
<string> phone number
# Example
# Search users
UsersManagementClient().search(query, options, page, limit)
Search users based on keywords
# Parameters
query
<null> search contentoptions
<string[]> optionsoptions.fields
<string[]> Search user fields, if not specified, the default will be fuzzy search from username, nickname, email, phone, company, name, givenName, familyName, middleName, profile, preferredUsername fields . If you need precise search, please use the find method.page
<number> The default value is:1
.limit
<number> The default value is10
.
# Example
String query = "query";
PaginatedUsers users = managementClient.users().search(query).execute();
# Refresh user token
UsersManagementClient().refreshToken(id)
Refresh user token
# Parameters
id
<string> User ID
# Example
RefreshToken token = managementClient.users().refreshToken("userId").execute();
# Get user group list
UsersManagementClient().listGroups(userId)
Get user group list
# Parameters
userId
<string> user ID
# Example
managementClient.users().listGroups("userId").execute();
# Join group
UsersManagementClient().addGroup(userId, group)
Add users to groups
# Parameters
userId
<string> user IDgroup
<string> group code
# Example
managementClient.users().addGroup("userId", "groupId").execute();
# Exit group
UsersManagementClient().removeGroup(userId, group)
Exit group
# Parameters
userId
<string> user IDgroup
<string> group code
# Example
managementClient.users().removeUdv("userId", "groupId").execute();
# Get user role list
UsersManagementClient().listRoles(userId)
Get the user's role list
# Parameters
userId
<string> user ID
# Example
PaginatedRoles roles = managementClient.users().listRoles("userId").execute();
# Add role
UsersManagementClient().addRoles(userId, roles)
Add users to roles
# Parameters
userId
<string> user IDroles
<string> role code list
# Example
ArrayList<String> roles = new ArrayList<>();
roles.add("role code");
managementClient.users().addRoles("userId", roles);
# Remove role
UsersManagementClient().removeRoles(userId, roles)
Remove user from role
# Parameters
userId
<string> user IDroles
<string> role code list
# Example
ArrayList<String> roles = new ArrayList<>();
roles.add("role code");
CommonMessage message = managementClient.users().removeRoles("userId", roles).execute();
# Get the user's organization
UsersManagementClient().listOrgs(userId)
Get the user's organization and his node path in the organization
# Parameters
userId
<string> user ID
# Example
List<List<Org>> orgs = managementClient.users().listOrgs("userId").execute();