Skip to main content

oauth2 link

Project description

oauth2link

让你的网站平台通过第三方平台快速登录授权,目前支持的平台有:

  • 新浪微博
  • GitHub

一、快速入门

  1. 安装项目包

    git clone https://github.com/Bean-jun/oauth2link.git
    python setup.py install
    
    # 或者
    pip install oauth2link
    
  2. 在项目中填写配置文件

    以微博为例:

    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
    
  3. 导入本包并初始化&编写回调逻辑(默认的回调逻辑应该是不满足业务需求的)

    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)
    
  4. 编写授权跳转页面

    from flask import redirect
    
    @app.get("/wei_login")
    def weibo_login():
        return redirect(links.redirect_url())
    

二、TODO

  • 实现多平台兼容运行

  • 纳入更多支持oauth2的第三方平台

Project details


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

oauth2link-0.0.4-py3-none-any.whl (14.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page