oauth2 link
Project description
oauth2link
让你的网站平台通过第三方平台快速登录授权,目前支持的平台有:
- 新浪微博
- GitHub
一、快速入门
-
安装项目包
git clone https://github.com/Bean-jun/oauth2link.git python setup.py install # 或者 pip install oauth2link
-
在项目中填写配置文件
以微博为例:
LINKS_WEIBO_CLIENT_ID LINKS_WEIBO_REDIRECT_URI LINKS_WEIBO_SCOPE LINKS_WEIBO_CLIENT_SECRET
以github为例:
LINKS_GITHUB_CLIENT_ID LINKS_GITHUB_REDIRECT_URI LINKS_GITHUB_SCOPE LINKS_GITHUB_CLIENT_SECRET
-
导入本包并初始化&编写回调逻辑(默认的回调逻辑应该是不满足业务需求的)
from oauth2link.platform import WeiBoOauth2 from oauth2link.callback import BaseCallBackHandler class MyCallBackHandler(BaseCallBackHandler): def do_call(self): self.oauth_client.get_access_token(request) self.oauth_client.get_user_info() self.oauth_client.save_model() ... links = WeiBoOauth2() links.CALLBACK_HANDLER = MyCallBackHandler links.init_app(app)
-
编写授权跳转页面
from flask import redirect @app.get("/wei_login") def weibo_login(): return redirect(links.redirect_url())
二、TODO
-
实现多平台兼容运行
-
纳入更多支持oauth2的第三方平台
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 Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
File details
Details for the file oauth2link-0.0.4-py3-none-any.whl
.
File metadata
- Download URL: oauth2link-0.0.4-py3-none-any.whl
- Upload date:
- Size: 14.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 106a6df68938c56a2410e4f799094b683807c0d844907c7e029685d0b91c3041 |
|
MD5 | ecb63fb3d47d1c45949389bcb463e0dd |
|
BLAKE2b-256 | 58088b1bfb0816bbb818d0b8398e7d46bf51374b961fb8f3d4c099d69b7ca31b |