docebo lms的单点登录实现
doceboSSO的Python项目详细描述
这个包允许一个简单的python接口添加第三个 单方登录Docebo学习管理系统。Docebo的 SSO不创建不存在的用户,或更新凭据。 存在的用户的。
用法
有两种方法可以使用此包,具体取决于 Docebo登录时需要的自定义。
用户api
用户API是一种简单、灵活的同步DoeBo用户的方法集。 使用本地创建的用户对象。要使用这些方法,docebooser 对象必须首先用要实例化的所有信息 与Docebo中的用户同步
有效用户参数的完整列表可以在Docebo的API中找到 参考: https://www.docebo.com/wp-content/uploads/media/Docebo_APImanual.pdf
from doceboSSO import docebo_user new_user= DoceboUser(userid='batman', firstname='john', lastname='Doe', ... )
接下来,lms的api和sso密钥以及托管域必须是 已初始化。此方法还将创建适当的散列和 使用Docebo的API所需的标记
new_user.initialize_keys(domain='http://example.docebosaas.com'api_key='xxxxxxxxxx'api_secret='xxxxxxxxxx'sso_token='xxxxxx')
最后,可以使用docebouser api中的方法与 Docebo–这些方法使用您输入到Docebouser中的参数 对象并生成有效的params/api_键。
if new_user.verify_existence(): new_user.update_on_docebo()else: new_user.create()redirect_url= new_user.signin()
上面是一个简单的脚本,用于创建在 第一步,如果在DOCEBO上不存在他们的用户ID,并更新它们 用户参数,如果它们确实存在。
重定向到将包含一个有效的、已签名的URL以登录到该用户的 Docebo上的帐户,可以重定向到浏览器或粘贴到浏览器中。
以下调用也可用于更新指定的用户 本地docebooser上的属性。然后可以将此信息推送到 docebo/用于创建新用户。
new_user.update_info_locally(firstname='jane', lastname='dae', ... )
可用的方法有:
All of these methods return boolean values for success for easy control flow from doceboSSO import docebo_user # Initialize user object with keys, secrets and domain initialize_keys(self, domain, api_secret, api_key, sso_secret)# Verify user exists in Docebo # Hits /api/user/checkUsername verify_existence(self)# Update remote user params given local user information update_on_docebo(self)# Create a new user based on local user # Hits /api/user/create create(self)# Delete user # Hits /api/user/delete delete(self)# Sign user in (if account exists), and return URL which will sign that user into their docebo account signin(self)# Update local user's information update_info_locally
要调用docebo上的delete或update,需要给定用户的docebo唯一ID。
您也可以使用以下方法手动添加uid。
new_user.set_docebo_unique_id(#####)
方法API
第二种交互方法不那么抽象,但是给了用户 更多的控制参数。用户api生成参数和 为用户填写信息,方法api要求用户 每次调用时输入一组参数作为字典。
可以找到为每个方法生成的参数的正确格式 地点: https://www.docebo.com/wp-content/uploads/media/Docebo_APImanual.pdf
api_密钥、api_机密和sso_机密仍必须初始化为 在用户api中。
可用的方法有:
These methods return the json body of the responses they receive. # Verify user exists in Docebo verify_user(self, params)# Update user params w/input params edit_user(self, params)# Create a new user given input params # If called on a user that already exists, returns None create_user(self, params)# Delete user corresponding to provided unique_id delete_user(self, params)# Sign user in (if account exists), and return URL which will sign that user into their docebo account setup_valid_sso_path_and_params(self, username)