Authlib: Python Authentication

Release v0.11.dev. (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.5+.

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.

User Guide

This part of the documentation begins with some background information about Authlib, and installation of Authlib.

API Reference

If you are looking for information on a specific function, class or method for non specifications, this part of the documentation is for you.