Authlib: Python Authentication

Release v0.13. (Installation)

The ultimate Python library in building OAuth and OpenID Connect servers. It is designed from low level specifications implementations to high level frameworks integrations, to meet the needs of everyone.

Authlib is compatible with Python2.7+ and Python3.6+.

Overview

A simple Flask OAuth Client which connects to the GitHub OAuth2 API:

from flask import Flask
from authlib.flask.client import OAuth
# use loginpass to make OAuth connection simpler
from loginpass import create_flask_blueprint, GitHub

app = Flask(__name__)
oauth = OAuth(app)

def handle_authorize(remote, token, user_info):
    if token:
        save_token(remote.name, token)
    if user_info:
        save_user(user_info)
        return user_page
    raise some_error

github_bp = create_flask_blueprint(GitHub, oauth, handle_authorize)
app.register_blueprint(github_bp, url_prefix='/github')

OAuth server (provider) on the other hand is a little complex, find a real Flask OAuth 2.0 Server via Example of OAuth 2.0 server.

Get Updates

Stay tuned with Authlib, here is a history of Authlib changes.

Consider to follow Authlib on Twitter, and subscribe Authlib Blog.