docebo lms的单点登录实现
docebo-sso的Python项目详细描述
这个包允许一个简单的python接口添加第三个 单方登录Docebo学习管理系统。Docebo的 SSO不创建不存在的用户,或更新凭据。 存在的用户的。
用法
有两种方法可以使用此包,具体取决于 Docebo登录时需要的自定义。
用户api
用户API是一种简单、灵活的同步DoeBo用户的方法集。 使用本地创建的用户对象。要使用这些方法,用户对象 必须首先用要同步的所有信息实例化 Docebo的用户
有效用户参数的完整列表可以在Docebo的API中找到 参考: https://www.docebo.com/wp-content/uploads/media/Docebo_APImanual.pdf
from docebo_sso import user as docebo_user new_user= docebo_user.User(userid='batman', firstname='john', lastname='Doe', ... )
接下来,lms的api和sso密钥以及托管域必须是 已初始化。此方法还将创建适当的散列和 使用Docebo的API所需的标记
docebo_user.initialize_keys(domain='http://example.docebosaas.com'api_key='xxxxxxxxxx'api_secret='xxxxxxxxxx'sso_token='xxxxxx')
最后,可以使用用户api中的方法与docebo交互 –这些方法使用输入到用户对象中的参数, 生成有效的params/api_密钥。
if new_user.exists(): new_user.update()else: new_user.create()redirect_url= new_user.signin()
上面是一个简单的脚本,用于创建在 第一步,如果在DOCEBO上不存在他们的用户ID,并更新它们 用户参数,如果它们确实存在。
重定向URL将包含一个有效的、已签名的URL以登录到该用户的 Docebo上的帐户,可以重定向到浏览器或粘贴到浏览器中。
可用的方法有:
All of these methods return boolean values for success for easy control flow from docebo_sso import user as docebo_user # Initialize user object with keys, secrets and domain docebo_user.initialize_keys(self, domain, api_secret, api_key, sso_secret)# Verify user exists in Docebo (by username) # Hits /api/user/checkUsername exists(self)# Update remote user params from local user information update(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)
为了调用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中。
可用的方法有:
from docebo_sso import methods as docebo_methods #These methods return the json body of the responses they receive. # Verify user exists in Docebo docebo_methods.verify_user(self, params)# Update user params w/input params docebo_methods.edit_user(self, params)# Create a new user given input params # Gives an 'empty response' error if user already exists docebo_methods.create_user(self, params)# Delete user corresponding to provided unique_id docebo_methods.delete_user(self, params)# Sign user in (if account exists), and return URL which will sign that user into their docebo account docebo_methods.setup_valid_docebo_sso_path_and_params(self, username)