YIDU UCenter SDK.
Project description
- Info:
该组件是提供给应用方使用的,用来访问用户中心功能的SDK
- Maintainer:
qibin.jin(qibin.jin@yiducloud.cn), shiwei.ma(shiwei.ma@yiducloud.cn)
About
ucenter-sdk 是架构组新用户中心系统提供的SDK。 用于辅助内部应用开发者快速接入新用户中心,对接并完成如: 登录 , 用户信息管理 , 应用信息管理 , 权限管理 , 单点登录功能 , 应用间授权管理等功能 。 部分文档已经更新和发布,包括一个简明教程,用户指南和 API参考手册 。
Supported Ucenter Versions
ucenter-sdk 现支持Ucenter v2.0.0
Installation
我们推荐使用 pip 。你可以使用 pip install -i http://devpi.intra.yiducloud.cn/root/yiducloud/+simple/ --trusted-host devpi.intra.yiducloud.cn -U ucenter-sdk 来安装它。
Dependencies
ucenter-sdk 所依赖的可以通过 pip 安装。 使用ucenter-sdk 你需要满足:
requests>=2.1.0
Examples
Some simple examples of what MongoEngine code looks like:
# -*- coding:utf-8 -*-
from ucenter_sdk import uc_call
# 应用名,应用必须在统一用户中心中有注册
# 如果是新应用,可以找管理员添加
app_name = 'dep-platform'
# 应用间授权(OAUTH2)凭证
# 在统一用户中心中申请(由管理员添加)
oauth2_req_args = {
'client_id': 'open-platform', # type: str
'client_secret': 'open-platform-secret',
'grant_type': 'client_credentials',
'scope': 'cluster:all org:all app:all',
}
# 应用所在的集群
# 默认不需要用户指定,会在运行时,由平台的环境变量自动赋值。
#cluster_name = '用户中心cluster'
# 用户中心服务地址
# 默认不需要用户指定,会在运行时,由平台的环境变量自动赋值。
uc_uri = 'http://localhost:5102'
ucenter = uc_call(client_credential=oauth2_req_args, app_name=app_name, uc_uri=uc_uri)
login_name = 'super_admin'
password = '123456'
ucenter_user = ucenter.login_check(login_name=login_name, password=password)
print(ucenter_user)
>>>
{
"username": "super_admin",
"app": "{'status': 0, 'by_uid': u'用户中心', 'createAt': '2018-11-13 21:12:52', 'name': u'用户中心app', 'updateAt': '2018-11-13 21:12:52', 'removed': False, 'type': u'inner', 'id': '5bc87f1059179433b79d8aa1', 'desc': u'用户中心'}",
"phone": null,
"updateAt": "2018-11-13T21:12:53.200000",
"id": "5beacdd5bda7532ebbbd3592",
"auth_phone": false,
"userid": "super_admin",
"auth_email": false,
"ext": {
"title": null,
"createAt": null,
"attrs": null,
"department": null,
"updateAt": null,
"id": null
},
"createAt": "2018-11-13T21:12:53.201000",
"fullname": "super_admin",
"email": null
}
Tests
运行测试用例
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ucenter_sdk-1.0.13.tar.gz
(20.0 kB
view hashes)
Built Distribution
Close
Hashes for ucenter_sdk-1.0.13-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff7f8692454a5cec4dd4a3b4b6d95ebddb262050cda5e7073fc8371f96b90448 |
|
MD5 | 97d4f653e3150b6933e3d46082574181 |
|
BLAKE2b-256 | 2bf8c36aebf374a529c5b7ce177b802a11f68ce8931cbadb63a3edc07be5421d |