Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query params limit does not work properly in list_application_users() #423

Open
qbui-os opened this issue Oct 19, 2024 · 0 comments
Open

Comments

@qbui-os
Copy link

qbui-os commented Oct 19, 2024

When trying to list all application users using Pagination (while resp.has_next()), the query param limit does not work. Okta will just ends up fetching all the application users.

Without pagination, the query param limit works.
However, when using with pagination (which is required to fetch a number of users > default page size: 50), the limit becomes the batch size of users to fetch in each page.

Code

I added a custom break to stop the client when the number of users fetched > limit.

async def list_okta_app_users(okta_conf: dict, filter: str = "", limit: int = 0) -> list[AppUser]:
    app_users: list[AppUser] = []
    q_params: dict = {}
    if filter:
        q_params["filter"] = filter
    if limit:
        q_params["limit"] = limit

    # Query Okta for application users
    async with OktaClient(user_config=okta_conf) as client:
        users, resp, err = await client.list_application_users(okta_conf['clientId'], q_params)
        while resp.has_next():
            app_users.extend(users)
            users, err = await resp.next()
            if err:
                print(err)
                break

            # Custom break
            if len (app_users) > q_params["limit"]:
                print(f"Okta Client fetched more users than specified query params limit: {q_params['limit']}")
                break

        return app_users

Screenshot

Screenshot 2024-10-19 at 16 56 46

Expectation

The query param limit is specified, when resp.has_next() should return False to stop fetching more users.

Okta version

Latest: v2.9.8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant