Treer SSO SDK - OAuth 2.0客户端SDK,用于快速集成Treer SSO服务
Project description
Treer SSO SDK
🚀 用于快速集成Treer SSO服务的Python SDK,支持OAuth 2.0授权码流程
✨ 特性
- 🔐 OAuth 2.0支持: 完整的授权码流程实现
- ⚡ 异步支持: 基于httpx的高性能异步HTTP客户端
- 🛡️ 类型安全: 完整的类型提示支持
- 🔧 易于集成: 提供便捷函数和高级客户端类
- 📖 完整文档: 详细的API文档和使用示例
- 🧪 测试覆盖: 高质量的单元测试
- 🐍 现代Python: 支持Python 3.11+
🚀 快速开始
安装
pip install treer-sso-sdk
基础使用
import asyncio
from treer_sso_sdk import get_user_info_by_code
async def main():
user_info = await get_user_info_by_code(
authorization_code="your_auth_code",
client_id="your_client_id",
client_secret="your_client_secret"
)
print(f"用户: {user_info.username}")
print(f"邮箱: {user_info.email}")
asyncio.run(main())
高级使用
import asyncio
from treer_sso_sdk import TreerSSOClient, SSOConfig
async def main():
config = SSOConfig(
client_id="your_client_id",
client_secret="your_client_secret",
sso_base_url="https://sso-api.treer.ru"
)
async with TreerSSOClient(config) as client:
# 获取访问令牌
token_response = await client.get_access_token("auth_code")
# 获取用户信息
user_info = await client.get_user_info(token_response.access_token)
print(f"用户ID: {user_info.id}")
print(f"用户名: {user_info.username}")
asyncio.run(main())
📚 文档
🔧 开发
本地开发设置
# 克隆仓库
git clone https://github.com/treer-ru/treer-sso-sdk.git
cd treer-sso-sdk
# 安装开发依赖
pip install -e .[dev]
# 运行测试
pytest tests/
# 代码格式化
black src/
isort src/
# 类型检查
mypy src/treer_sso_sdk/
构建和发布
# 使用构建脚本
python scripts/build.py all
# 或手动构建
python -m build
twine check dist/*
🤝 贡献
欢迎贡献代码!
开发流程
- Fork 项目
- 创建功能分支 (
git checkout -b feature/amazing-feature) - 提交更改 (
git commit -m 'Add amazing feature') - 推送分支 (
git push origin feature/amazing-feature) - 创建 Pull Request
📄 许可证
本项目采用 MIT 许可证 - 详见 LICENSE 文件。
🔗 相关链接
💬 支持
如果您遇到问题或有疑问:
- 📋 提交Issue
- 📧 发送邮件至: dev@treer.ru
⭐ 如果这个项目对您有帮助,请给我们一个star!
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
treer_sso_sdk-1.0.0.tar.gz
(17.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file treer_sso_sdk-1.0.0.tar.gz.
File metadata
- Download URL: treer_sso_sdk-1.0.0.tar.gz
- Upload date:
- Size: 17.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eeb5749eef7bdb475a19c77a982fb74f4ff7dbc6274729209d3bb6adcc26014a
|
|
| MD5 |
6ec10d52be02b66a1340b8c65fbeaec1
|
|
| BLAKE2b-256 |
52fd92b53bca360b1e624a7b79c9a9cacbd3a4e0cb95c40ead90bd261c3bd84e
|
File details
Details for the file treer_sso_sdk-1.0.0-py3-none-any.whl.
File metadata
- Download URL: treer_sso_sdk-1.0.0-py3-none-any.whl
- Upload date:
- Size: 17.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8364238d99b97e8ccf8c904b7a713adceafc48799e7199e06c31f975d0bf4433
|
|
| MD5 |
08a4e8848abaf47c0925ced736097d50
|
|
| BLAKE2b-256 |
f609082e2e2a7489d733da9a17ee432a29b3a1c490007fc6606caab5b23b7519
|