Skip to main content

Ucenter SDK

Info:

该组件是提供给应用方使用的,用来访问用户中心功能的SDK

Author:

shiwei.ma (shiwei.ma@yiducloud.cn)

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

运行测试用例

Release files for ucenter-sdk 1.0.13

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ucenter-sdk 1.0.13
File Size Uploaded
ucenter_sdk-1.0.13.tar.gz 20.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ucenter-sdk 1.0.13
File Interpreter ABI Platform
ucenter_sdk-1.0.13-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 44.7 kB

Release files / ucenter_sdk-1.0.13.tar.gz

Download URL ucenter_sdk-1.0.13.tar.gz
Size 20.0 kB
Tags Source
SHA-256 checksum
How to use checksums
8446d73d10bd31912b62bedb623f638efd362044d0dca30efc437a40f8b28e60
BLAKE2b-256 checksum
How to use checksums
6770bc438d37f08d91c8fdd27d8c4719aadf0fed568bcd08d0b723b8effc7f51
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/2.7.16

Release files / ucenter_sdk-1.0.13-py2.py3-none-any.whl

Download URL ucenter_sdk-1.0.13-py2.py3-none-any.whl
Size 24.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
ff7f8692454a5cec4dd4a3b4b6d95ebddb262050cda5e7073fc8371f96b90448
BLAKE2b-256 checksum
How to use checksums
2bf8c36aebf374a529c5b7ce177b802a11f68ce8931cbadb63a3edc07be5421d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/2.7.16

Release history Release notifications | RSS feed

This release

1.0.13 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page