Getting groups for a user using Python SDK

Hi,

I’m trying to get the groups that a user is a member of using the python SDK. I need to call this API - Users | Okta Developer. How can I do this using the python SDK? I wasn’t able to find anything here - GitHub - okta/okta-sdk-python. Thanks in advance for your help.

You can use the the method Add User To Group By ID:

from okta import UserGroupsClient

groups_client = UserGroupsClient("https://{org}.oktapreview.com", "API_KEY")
group = groups_client.get_groups(query="UniqueGroupName")[0]

# Add user to group by ID
groups_client.add_user_to_group_by_id(group.id, user.id)

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