# snowland-auth-sdk-python **Repository Path**: snowlandltd/snowland-auth-sdk-python ## Basic Information - **Project Name**: snowland-auth-sdk-python - **Description**: No description available - **Primary Language**: Python - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2019-03-15 - **Last Updated**: 2026-08-11 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # snowland-auth-sdk-python [![Version](https://img.shields.io/badge/Python-3.8|3.9|3.10|3.11|3.12-yellowgreen.svg)]() [![License](http://img.shields.io/:License-apache-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0.html) [![PyPI Version](https://img.shields.io/pypi/v/snowland-authsdk)](https://gitee.com/snowlandltd/snowland-auth-sdk-python) [![Downloads](https://img.shields.io/pypi/dm/snowland-authsdk?cacheSeconds=86400)](https://pypi.org/project/snowland-authsdk) 提供统一的第三方 OAuth 登录(GitHub/Gitee/CSDN/微信/企业微信/支付宝/阿里云/1688 等)与 Snowland 自有授权能力。 ## 特性 - 支持 Snowland 自有授权体系以及多平台第三方 OAuth 登录 - 统一的 `BaseOAuthClient` 抽象,各平台客户端接口一致 - 基于 `snowland-http` 实现同步/异步两种 HTTP 调用方式 - 不依赖 `requests` / `astartool`,仅使用标准库与 `snowland-http` ## 支持的第三方平台 GitHub、Gitee、CSDN、微信、企业微信、支付宝、阿里云、1688、Snowland ## 安装 ```bash pip install snowland-authsdk ``` ## 使用 ### 方式一:Snowland 自有授权(兼容旧接口) 1. 首先要去snowland-auth网站上注册一个账号 2. 从snowland-auth网站上新建一个应用,获得应用的access_key, access_secrte 3. 如demo所示 - 创建oauth对象 ```python from snowland_authsdk.login import OAuth access_key = 'tuxf517fqdserop68z1m3zmf6bs6tkrf' access_secret = '2446ea7d1722da461052d547268480b5aca159a781ccba27908a3acde887889c' app = OAuth(access_key, access_secret) ``` - 重定向url,使得用户向三方服务器发起请求 ```python res = app.oauth_authorize(**param, **user) ``` - 获取用户的code,并以此申请三方服务器的token ```python res = app.oauth_access_token(**{"code": code, "method":'post'}) ``` - 通过token向三方申请数据 ```python res = app.oauth_access_token(**{"code": code, "method": 'get'}) ``` ### 方式二:第三方 OAuth 登录(新模块) 以 GitHub 为例: ```python from snowland_authsdk.oauth import GitHubOAuthClient client = GitHubOAuthClient( client_id='your_client_id', client_secret='your_client_secret', redirect_uri='https://your-app/callback', ) # 1. 引导用户跳转授权页 authorize_url = client.get_authorize_url(state='random_state') # 2. 回调后,用 code 换取用户信息 user = client.get_userinfo(code='code_from_callback') ``` 各平台客户端均在 `snowland_authsdk.oauth` 下,例如 `GitHubOAuthClient`、`GiteeOAuthClient`、`WeChatOAuthClient`、 `WeChatWorkOAuthClient`、`AlipayOAuthClient`、`AliyunOAuthClient`、 `Alibaba1688OAuthClient`、`CsdnOAuthClient`、`SnowlandOAuthClient`。 ## 接入登记 更多接入的公司,欢迎在 登记地址 登记,登记仅仅为了产品推广。 以下公司或组织直接或间接应用了本项目 - A.Star算法组 - 河北雪域网络科技有限公司 ... ## Copyright and License This product is open source and free, and will continue to provide technical support. Individual or enterprise users are free to access and use. Licensed under the Apache v2.0 License (Apache 2.0). Copyright (c) 2019-present, Snowland Co,.Ltd 产品开源免费,并且将持续提供技术支持。个人或企业内部可自由的接入和使用。 ## Donate No matter how much the amount is enough to express your thought, thank you very much :) To donate 无论金额多少都足够表达您这份心意,非常感谢 :)