将Okta用户添加到Okta组Python sdk

时间:2015-06-11 16:53:49

标签: okta okta-api

是否有方法将用户添加到Okta组?我看到update_group,但没有具体说明如何将用户添加到Okta组。

1 个答案:

答案 0 :(得分:1)

SDK的最新更新在add_user_to_group(group, user)上有add_user_to_group_by_id(gid, uid)UserGroupsClient个方法。

from okta import UserGroupsClient
from okta.models.usergroup import UserGroup
from okta import UsersClient
from okta.models.user import User

groups_client = UserGroupsClient('your_url', 'your_key')
users_client = UsersClient('your_url', 'your_key')

# Create group
group = UserGroup(name='sample_name', 
                  description='sample description')
group = groups_client.create_group(group)

# Create user
user = User(login='sample@asdf.com',
            email='fake@asdf.com',
            firstName='Joe',
            lastName='Schmoe')
user = users_client.create_user(user, activate=False)

groups_client.add_user_to_group(group, user)
# or
groups_client.add_user_to_group_by_id(group.id, user.id)

获取最新信息:

pip install git+git://github.com/okta/oktasdk-python@master