Skip to content

A flask extension to help validate tokens from a different resource server.

Notifications You must be signed in to change notification settings

michaelbukachi/flask-authlib-client

Repository files navigation

Flask-Authlib-Client

Build Status

Flask-Authlib-Client is a Flask extension that adds support for separate authorization/resource servers. It extends authlib's flask integration. This extension is heavily inspired by django-oauth-toolkit

Install

$ pip install Flask-Authlib-Client

Usage

from flask import Flask
from authlib.integrations.flask_client import OAuth
from flask_authlib_client import AuthClient


class Config:
    # Other configurations
    RESOURCE_SERVER_INTROSPECTION_URL = 'http://someurl'
    RESOURCE_SERVER_INTROSPECTION_CREDENTIALS = ('test', 'test') # Client id and secret to authorization server



app = Flask(__name__)
app.config.from_object(Config)
oauth = OAuth(app)
ac = AuthClient(app, oauth)

# protect your endpoints
@app.route('/')
@ac.require_oauth()
def example():
    return 'Ok'

@app.route('/')
@ac.require_oauth('home') # Specify scope
def example():
    return 'Ok'

Issues

Feel free to raise any issue here.

Contributions

All contributions are welcome:smile:.

About

A flask extension to help validate tokens from a different resource server.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages