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

get_group_users returns only 1000 elements #73

Closed
Mogost opened this issue Apr 11, 2019 · 8 comments
Closed

get_group_users returns only 1000 elements #73

Mogost opened this issue Apr 11, 2019 · 8 comments

Comments

@Mogost
Copy link

Mogost commented Apr 11, 2019

groups_client = UserGroupsClient(base_url=settings.OKTA_BASE_URL, api_token=settings.OKTA_API_TOKEN)
users = groups_client.get_group_users(gid)

users contains only first 1000 items.
After debug:
response = ApiClient.get_path(self, '/{0}/users'.format(gid))
'next' in response.links returns True

url = 'https://xxxx.okta.com/api/v1/groups/xxxxxxx/users'
params = None

Based on the description should return 10,000.
https://developer.okta.com/docs/api/resources/groups/#list-group-members
In any case, the case of large groups is not taken into account.

Also checked with postman. The same behavior.
I also suspect that other API methods may have a similar problem.

@nbarbettini
Copy link
Contributor

You're only getting 1 page of results (see Pagination). For both Postman and Python code, you need to keep retrieving pages by repeatedly grabbing the next link from the Location header until there isn't a next link anymore.

@Mogost
Copy link
Author

Mogost commented Apr 13, 2019

Thank you @nbarbettini, but I know about Pagination.
But code in that library does not work with pagination.
https://github.com/okta/okta-sdk-python/blob/master/okta/UserGroupsClient.py#L64

    def get_group_users(self, gid):
        response = ApiClient.get_path(self, '/{0}/users'.format(gid))
        return Utils.deserialize(response.text, User)

@nbarbettini
Copy link
Contributor

Ah, I gotcha. Sorry about that. This library is not currently being maintained, so you will have to write your own pagination code. You could look at get_paged_users for inspiration: https://github.com/okta/okta-sdk-python/blob/master/okta/UsersClient.py#L106-L128

@Mogost
Copy link
Author

Mogost commented Apr 16, 2019

TY. I have already solved the problem in this way. This is just a issue to fix in the future. Perhaps I will make a pullrequest if I have time.

@nbarbettini
Copy link
Contributor

👍 Thanks for reporting! I'll leave this open, although we aren't currently planning any Python work in the near future.

@bretterer
Copy link
Collaborator

We have recently released a 1.x version of this SDK and all api calls and setup is different which should resolve this issue. Please check out our new version on PyPi.

This new release includes pagination capabilities which should resolve this issue for you.

If you find that you are still having an issue, please let us know if you are still having this issue.

@Andrey-Danilenko
Copy link

@bretterer Hello! I've got the several problem in SDK ver. 1.6.0
I used OktaClient::list_group_users() method and got only 200 records. I tried to use query_params.limit, but it worked only with numbers lesser than 200. Seems like 200 is a hard limit, and SDK force me to use pagination. Can I off the pagination or set limit more than 200 in some way?
Thank you!

@serhiibuniak-okta
Copy link
Contributor

@Andrey-Danilenko Yes, 200 is a hard limit and you have to use pagination (it doesn't depend on SDK). How to use pagination with Python SDK - https://github.com/okta/okta-sdk-python#pagination

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

5 participants