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

Getting all users using get_users #63

Closed
DustinCarleton opened this issue Nov 15, 2018 · 7 comments
Closed

Getting all users using get_users #63

DustinCarleton opened this issue Nov 15, 2018 · 7 comments

Comments

@DustinCarleton
Copy link

Good Morning,

I am having an issue using the get_users command. In DUO's Admin API, it states that only 300 users can be pulled at a time, and that I would have to specify an offset to get the next 300 users. So far, using the get_users command, I am able to pull up to at least 500 users with no issue. However, if this is an error on DUO's end and they end up correcting the error my script will no longer function. Would you be able to tell me the proper syntax of grabbing all the user's in groups of 300 at a time, using the offset?

Thank you,
Dustin

@duopeter
Copy link

Hi Dustin!

The documented max may not currently be enforced, but it will be in the near future. Consider the "limit" parameter a request, but the server may decide to return whatever number of results it wants.
The returned JSON result includes a "next_offset" value that tells you what is the next offset you should use to continue paging through the results.

The current python client library doesn't help much with this, but we'll be updating it to do that soon. It is probably easiest to wait for that update.

@dustindoucette
Copy link

Hi again,

Just had a quick question that is probably stupidly obvious. I noticed you just updated the 'admin.py' to include the offset and limit parameters. I was wondering if those changes will be reflected soon when I install the module in Python using the "python -m pip install duo_client" command. Right now I can get it working by manually installing the python file and creating the pyc for it.

Thank you,
Dustin

@xdesai
Copy link
Contributor

xdesai commented Dec 7, 2018

Hi Dustin,
I may have a misunderstanding, but I believe that
python -m pip install duo_client is pulling from https://pypi.org/project/duo_client/
We haven't updated duo_client hosted there just yet because we're waiting to get a couple more pagination pull requests in. We'll tag a release and update pypi hopefully sometime next week.

@keithhir
Copy link

Forgive me to adding to this topic, but when pagination is required, will the client automatically send another get_users call with the next_offset parameter, or will we need to manually call get_users each time until we no longer see next_offset in the JSON result?

@xdesai
Copy link
Contributor

xdesai commented Dec 12, 2018

Hi!
So the way we've designed this feature is to allow you to have it both ways. If you want us to handle the pagination for you then we will. If you want to handle pagination yourself then we let you do that too.

If you want us to handle pagination on, let's say, the get_users() call then what you'll want to do is call get_users() with no arguments. This will automatically do all the pagination and give you the result.
If you want more fine grain control then you can pass in a limit and an offset as arguments to get_users. get_users(limit=100, offset=200) This will only return the 100 users starting at offset 200.
Does that make sense?

@keithhir
Copy link

Yes, that answers my question perfectly. I would appreciate the option to make one call and have the pagination automatically taken care of, in addition to having manual control. Thank you!

@xdesai
Copy link
Contributor

xdesai commented Dec 14, 2018

Duo Client Python 4.1.0 is released and can be imported via pip! Also the Duo API will now properly respect pagination args.
Closing out this issue now. Thanks for using Duo!

https://pypi.org/project/duo-client/4.1.0/

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