for user in users:
print(user.profile.first_name)
counter += 1
print(counter)
while resp.has_next():
users, err = await resp.next()
for user in users:
print(user.profile.first_name)
counter += 1
print(counter)
print(counter)
while True:
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
I would like to use this but with a GROUP ID so it does not get all the users in the okta instance but only the users in the group.
Here’s a quick and dirty sample. When I tested it, I received all of users in the provided group. I’m just printing out the length of my output here to check the right number of users were returned, and when I ran it, I got an output of 617, which was a match for the membership count the Admin Console reported as well.
That is working for the length. But my group have few thousand users in it and at max I can fetch is 1000. Does this means I have to use some pagination in it.
print(len(users_in_group))
print(resp)
print(err)
######### if / else condition #########
while True:
if resp.has_next():
print(resp.has_next())
users, err = await resp.next()
print(‘This is next set of users’)
print(len(users_in_group))
######### if / else condition ######### (Same as above conditional)
else:
break
All right, I added some more users to my org to test the pagination. This ended up working for me to get the full list of users (again, I’m just counting them):
okta_client = OktaClient(config)
async def main():
users = []
users_in_group, resp, err = await okta_client.list_group_users("00ghtuczwIbPhbTvH356")
while True:
for user in users_in_group:
users.append(user)
if resp.has_next():
users_in_group, err = await resp.next()
else:
break
print(len(users))
loop = asyncio.get_event_loop()
loop.run_until_complete(main())