Okta Java SDK Client.listUsers() only returning first 200 users

The following code is only returnning the first 200 users when I attempt to either loop or stream through the UserList that is returned from Client.listUsers(). Am I doing something wrong? I though pagination would be handled via the Okta Java SDK.

    public Client getClient(String oktaDomain, String apiToken) {
        String oktaUrl = "https://" + oktaDomain;

        return Clients.builder()
                .setClientCredentials(new TokenClientCredentials(apiToken))
                .setScopes(new HashSet<>(Collections.singletonList("okta.users.read")))

    public UserList getUserData(String domain, String apiToken) throws CustomAllowRetryException {
        Client client = getClient(domain, apiToken);
        UserList userList;
        try {
            logger.info("Gathering user list from Okta.", v("domain", domain));
            userList = client.listUsers();
        } catch (RuntimeException runtimeException) {
            logger.error("Unable to retrieve Users from Okta account for domain.", v("domain", domain), v("message", runtimeException.getMessage()));
            throw new WombatAllowRetryException("Unable to retrieve Users from Okta account for domain");
        } catch (Exception exception) {
            logger.error("Unable to retrieve Users from Okta account for domain.", v("domain", domain), v("message", exception.getMessage()));
            throw new CustomAllowRetryException("Unable to retrieve Users from Okta account for domain");

        return userList;

Can you include the snippet you are using to loop through the UserList?

Yes, @bdemers, I’m running into issues while looping throught the list. One challenge is that I need to be able to retrieve each user’s manager’s email address and map it to that user inside my grpcService.

The following code starts with a UserList oktaUserList that comes from calling Client.listUsers().

// Create local cache of userIds and userEmails to use for mapping managerEmail
Map<String, String> oktaUserIdEmailCache = new HashMap<>();

// NOTE: This forEach() works successfully for 15,000 users
oktaUserList.forEach(user -> {
    oktaUserIdEmailCache.put(user.getId(), user.getProfile().getEmail());

int oktaUserListSize = oktaUserIdEmailCache.size();
int oktaUsersRemaining = oktaUserListSize;

List<com.okta.sdk.resource.user.User> oktaUserBatch = new ArrayList<>();
int oktaUserBatchNumber = 0;

// NOTE: This for loop is NOT working; Only goes through first 200 users
for (com.okta.sdk.resource.user.User user : oktaUserList) {
    if (oktaUserBatch.size() < BATCH_SIZE) {

    if (oktaUserBatch.size() == BATCH_SIZE || oktaUsersRemaining == 0) {
        if (oktaUsersRemaining == 0) {
            isFinished = true;

        // NOTE: This is where the managerEmail mapping takes place
        List<grcpcUser> grpcUsers = grpcService.convertOktaUserListToGrpcUserList(oktaUserBatch, oktaUserIdEmailCache);

        UserResponse response = grpcService.sendUsersToGrpcProcessor(grpcUsers, syncTypeName, id, correlationID, tenantUUID,
                adminEmail, isFinished, batchNumber, totalUserCount);

        if (oktaUsersRemaining > 0) {

On the second loop, are the user objects part of the last page?