Class UsersEntity

java.lang.Object
com.auth0.client.mgmt.UsersEntity

public class UsersEntity extends Object
Class that provides an implementation of the Users methods of the Management API as defined in https://auth0.com/docs/api/management/v2#!/Users and https://auth0.com/docs/api/management/v2#!/Users_By_Email

This class is not thread-safe.

See Also:
  • Field Details

    • client

      protected final Auth0HttpClient client
    • baseUrl

      protected final okhttp3.HttpUrl baseUrl
    • tokenProvider

      protected final TokenProvider tokenProvider
  • Method Details

    • listByEmail

      public Request<List<User>> listByEmail(String email, FieldsFilter filter)
      Request all the Users that match a given email. A token with scope read:users is needed. If you want the identities.access_token property to be included, you will also need the scope read:user_idp_tokens. See https://auth0.com/docs/api/management/v2#!/Users_By_Email/get_users_by_email
      Parameters:
      email - the email of the users to look up.
      filter - the filter to use. Can be null.
      Returns:
      a Request to execute.
    • list

      public Request<UsersPage> list(UserFilter filter)
      Request all the Users. A token with scope read:users is needed. If you want the identities.access_token property to be included, you will also need the scope read:user_idp_tokens. See https://auth0.com/docs/api/management/v2#!/Users/get_users
      Parameters:
      filter - the filter to use. Can be null.
      Returns:
      a Request to execute.
    • get

      public Request<User> get(String userId, UserFilter filter)
      Request a User. A token with scope read:users is needed. If you want the identities.access_token property to be included, you will also need the scope read:user_idp_tokens. See https://auth0.com/docs/api/management/v2#!/Users/get_users_by_id
      Parameters:
      userId - the id of the user to retrieve.
      filter - the filter to use. Can be null.
      Returns:
      a Request to execute.
    • create

      public Request<User> create(User user)
      Create a User. A token with scope create:users is needed. See https://auth0.com/docs/api/management/v2#!/Users/post_users
      Parameters:
      user - the user data to set
      Returns:
      a Request to execute.
    • delete

      public Request<Void> delete(String userId)
      Delete an existing User. A token with scope delete:users is needed. See https://auth0.com/docs/api/management/v2#!/Users/delete_users_by_id
      Parameters:
      userId - the user id
      Returns:
      a Request to execute.
    • update

      public Request<User> update(String userId, User user)
      Update an existing User. A token with scope update:users is needed. If you're updating app_metadata you'll also need update:users_app_metadata scope. See https://auth0.com/docs/api/management/v2#!/Users/patch_users_by_id
      Parameters:
      userId - the user id
      user - the user data to set. It can't include id.
      Returns:
      a Request to execute.
    • getEnrollments

      public Request<List<Enrollment>> getEnrollments(String userId)
      Retreive the first confirmed enrollment, or a pending enrollment if none are confirmed. A token with scope read:users is needed. See https://auth0.com/docs/api/management/v2#!/Users/get_enrollments
      Parameters:
      userId - the id of the user to retrieve.
      Returns:
      a Request to execute.
    • getLogEvents

      public Request<LogEventsPage> getLogEvents(String userId, LogEventFilter filter)
      Request all the Events Log for a given User. A token with scope read:logs is needed. See https://auth0.com/docs/api/management/v2#!/Users/get_logs_by_user
      Parameters:
      userId - the id of the user to retrieve.
      filter - the filter to use.
      Returns:
      a Request to execute.
    • deleteAllAuthenticators

      public Request<Void> deleteAllAuthenticators(String userId)
      Delete all an user's authenticators. A token with scope delete:guardian_enrollments is needed. See API docs
      Parameters:
      userId - the user id
      Returns:
      a Request to execute.
    • deleteMultifactorProvider

      public Request<Void> deleteMultifactorProvider(String userId, String provider)
      Delete an existing User's Multifactor Provider. A token with scope update:users is needed. See https://auth0.com/docs/api/management/v2#!/Users/delete_multifactor_by_provider
      Parameters:
      userId - the user id
      provider - the multifactor provider
      Returns:
      a Request to execute.
    • rotateRecoveryCode

      public Request<RecoveryCode> rotateRecoveryCode(String userId)
      Rotates a User's Guardian recovery code. A token with scope update:users is needed.
      Parameters:
      userId - the user id
      Returns:
      a Request to execute.
      See Also:
    • linkIdentity

      public Request<List<Identity>> linkIdentity(String primaryUserId, String secondaryUserId, String provider, String connectionId)
      Links two User's Identities. A token with scope update:users is needed. See https://auth0.com/docs/api/management/v2#!/Users/post_identities
      Parameters:
      primaryUserId - the primary identity's user id
      secondaryUserId - the secondary identity's user id
      provider - the provider name of the secondary identity.
      connectionId - the connection id of the secondary account being linked, useful if the provider is 'auth0' and you have several connections. Can be null.
      Returns:
      a Request to execute.
    • linkIdentity

      public Request<List<Identity>> linkIdentity(String primaryUserId, String secondaryIdToken)
      A token with scope update:current_user_identities is needed. It only works for the user the access token represents. See https://auth0.com/docs/api/management/v2#!/Users/post_identities
      Parameters:
      primaryUserId - the primary identity's user id associated with the access token this client was configured with.
      secondaryIdToken - the user ID token representing the identity to link with the current user
      Returns:
      a Request to execute.
    • unlinkIdentity

      public Request<List<Identity>> unlinkIdentity(String primaryUserId, String secondaryUserId, String provider)
      Un-links two User's Identities. A token with scope update:users is needed. See https://auth0.com/docs/api/management/v2#!/Users/delete_provider_by_user_id
      Parameters:
      primaryUserId - the primary identity's user id
      secondaryUserId - the secondary identity's user id
      provider - the provider name of the secondary identity.
      Returns:
      a Request to execute.
    • listPermissions

      public Request<PermissionsPage> listPermissions(String userId, PageFilter filter)
      Get the permissions associated to the user. A token with read:users is needed. See https://auth0.com/docs/api/management/v2#!/Users/get_permissions
      Parameters:
      userId - the role id
      filter - an optional pagination filter
      Returns:
      a Request to execute
    • removePermissions

      public Request<Void> removePermissions(String userId, List<Permission> permissions)
      Remove permissions from a user. A token with update:users is needed. See https://auth0.com/docs/api/management/v2#!/Users/delete_permissions
      Parameters:
      userId - the user id
      permissions - a list of permission objects to remove from the user
      Returns:
      a Request to execute
    • addPermissions

      public Request<Void> addPermissions(String userId, List<Permission> permissions)
      Assign permissions to a user. A token with update:users is needed. See https://auth0.com/docs/api/management/v2#!/Users/post_permissions
      Parameters:
      userId - the user id
      permissions - a list of permission objects to assign to the user
      Returns:
      a Request to execute
    • listRoles

      public Request<RolesPage> listRoles(String userId, PageFilter filter)
      Get the roles associated with a user. A token with read:users and read:roles is needed. See https://auth0.com/docs/api/management/v2#!/Users/get_user_roles
      Parameters:
      userId - the role id
      filter - an optional pagination filter
      Returns:
      a Request to execute
    • removeRoles

      public Request<Void> removeRoles(String userId, List<String> roleIds)
      Remove roles from a user. A token with update:users is needed. See https://auth0.com/docs/api/management/v2#!/Users/delete_user_roles
      Parameters:
      userId - the user id
      roleIds - a list of role ids to remove from the user
      Returns:
      a Request to execute
    • addRoles

      public Request<Void> addRoles(String userId, List<String> roleIds)
      Assign roles to a user. A token with update:users is needed. See https://auth0.com/docs/api/management/v2#!/Users/post_user_roles
      Parameters:
      userId - the user id
      roleIds - a list of role ids to assign to the user
      Returns:
      a Request to execute
    • getOrganizations

      public Request<OrganizationsPage> getOrganizations(String userId, PageFilter filter)
      Get the organizations a user belongs to. A token with read:users and read:organizations is required.
      Parameters:
      userId - the user ID
      filter - an optional pagination filter
      Returns:
      a Request to execute
      See Also:
    • voidRequest

      protected Request<Void> voidRequest(HttpMethod method, Consumer<com.auth0.client.mgmt.RequestBuilder<Void>> customizer)
    • request

      protected <T> Request<T> request(HttpMethod method, com.fasterxml.jackson.core.type.TypeReference<T> target, Consumer<com.auth0.client.mgmt.RequestBuilder<T>> customizer)