Python API listing users in a group

Hi There - I’ve been recently given access to the API in Okta (for our Org) and I can get a list of users on the web with a url like this one.
https://-admin.okta.com/api/v1/groups/00/users

but when I try to do this through Python, I can create the client object and I am using my api token I’m getting the error:

File “”, line 22, in main
TypeError: ‘NoneType’ object is not iterable

so to me it looks like 2 lines above where I’m calling list_group_users, nothing the variable isn’t getting set. Any reason why this would be?

async def main():
    users = []
    users_in_group, resp, err = await okta_client.list_group_users('00<our group id>')
    while True:
        for user in users_in_group: # THIS IS LINE 22
            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())

This has been hanging out here for 5 days now. Do I need to be some sort of superadmin on our domain or something for this to work (I have only been given access to a subset of groups)? It seems to me that I’ve configured the script correctly. I have a valid client, token and domain as far as I can tell but calling the function isn’t working. Using the group id in the browser does work.

I do know that I have limited access (by organizational design). For example when viewing a user and using “Verify Factors” (using Rockstar), I am denied access.

image

For anyone who finds this having the same issue, the specific PEBKAC error occurring that was not reflected in the stack was me using a token that was actually the token ID. Just know that the actual token is the one that only shows up once (I forgot that part). The actual token is much longer than 21 characters.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.