List all users with Python SDK Skip to main content
https://support.okta.com/help/answers?id=9062a000000qupqqa0&refurl=http%3a%2f%2fsupport.okta.com%2fhelp%2fanswers
How satisfied are you with the Okta Help Center?
Thank you for your feedback!
How satisfied are you with the Okta Help Center?
1
2
3
4
5
Very Dissatisfied
Very satisfied
Enter content less than 200 characters.
Ask Search:
Andre PerrotAndre Perrot 

List all users with Python SDK

I would like to get a list of all users and their user.id from my Okta org via Python. I've tried using the following example but it seems to be very slow (2 hours), I haven't seen it actually complete. Is there a better way to get a list of all active users via Python? My goal is to get all the user id's and then feed that to get_lifecycle_factors to get the enrollment date of the factor.

https://github.com/okta/okta-sdk-python/blob/master/docs/quickstart.rst
 
from okta import UsersClient
# http://developer.okta.com/docs/api/getting_started/getting_a_token.html
usersClient = UsersClient('My Site',
                          'My Token)

users = usersClient.get_paged_users()
while True:
    for user in users.result:
        print u"Login:      {}".format(user.profile.login)
        print u"User ID:    {}\n".format(user.id)
    if not users.is_last_page():
        # Keep on fetching pages of users until the last page
        users = usersClient.get_paged_users(url=users.next_url)
    else:
        break

 
Justin BergezJustin Bergez (Okta, Inc.)
Hi Andre,

The Python SDK does not do much, other than making a paginated call to list users. It can take hours to pull data, depending on the number of users in your org.
https://developer.okta.com/docs/api/resources/users.html#list-users.

Justin M. Bergez
Technical Support Engineer - Tier 2 | Okta, Inc.
1501885747483_PastedImage