Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

A simple Outh2 client

Project description

Oauth2 library for python flask and restplus

With this simple library, you can authenticate clients coming from a browser (Implicit Flow) or using Bearer token (Credential flow). You can manage authorization using rbac function as described here after.


Install these requirements


Usage example

import os
from flask import Flask
from flask_restplus import Api, Resource
from simple_oauth2 import OAuth

api = Api()
app = Flask(__name__)
app.secret_key = os.urandom(32)

oauth_config = {
    'well_known_url': '{well_known_url}',
    'client_id': '{client_id}',
    'redirect_uri': '{host:port}/signin-oidc',
    'audience': '{audience}',
    'scopes': '{coma separated scopes}',
    'whitelist': ['/openbar?']

def rbac(client, operation):
    print('client ', client, ' is asking for operation ', operation)
    return True

oauth = OAuth(app, oauth_config, rbac=rbac)

# flask
def slah():
    return 'Hello'

def hello():
    return 'hi'

def openbar():
    return 'Chimay'

# restplus
class Toto(Resource):
    def get(self):
        return {'hello': 'world'}

if __name__ == "__main__":'', debug=True)


Register here

Install required packages

python -m pip install --user --upgrade setuptools wheel
python -m pip install --user --upgrade twine

Package like this:

python sdist bdist_wheel
python -m twine upload --repository-url dist/*

Test install

pip install -i simple-oauth2

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for simple-oauth2, version 1.0.4
Filename, size File type Python version Upload date Hashes
Filename, size simple_oauth2-1.0.4-py3-none-any.whl (5.2 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size simple_oauth2-1.0.4.tar.gz (4.2 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page