Skip to main content

Flask-Rebar-Auth0 is a simple Flask-Rebar authenticator Auth0

Project description


PyPI version Python versions License: MIT

Simple Flask-Rebar authenticator for Auth0. Your access tokens need to be JWT tokens for this authenticator to work.


# Config
    "AUTH0_ENDPOINT": "",      # The Auth0 domain for your tenant
    "AUTH0_ALGORITHMS": ["RS256"],            # The authorized algorithms, you should not have to change it
    "AUTH0_AUDIENCE": "" # The API Identifier as set on Auth0

    "AUTH0_HEADER_AUTHENTICATION": True       # USe the authentication by header
    "AUTH0_HEADER_NAME": "Authorization"      # (OPTIONAL) Change the header used
    "AUTH0_HEADER_PREFIX": "Bearer"           # (OPTIONAL) Change the prefix used
    # OR
    "AUTH0_COOKIE_AUTHENTICATION": True       # Use the authentication by cookie
    "AUTH0_COOKIE_NAME": "Some Cookie"        # Name of the cookie containing the access token

# Create
authenticator = Auth0Authenticator(app)

def create_user(claims: Dict[str, Any]) -> Any:
    """Built a user object from the claims"""
    return { "id": claims["sub"] }


from flask_rebar_auth0 import get_authenticated_user

    authenticator=authenticator, # Use the authenticator
def get_user():
    return get_authenticated_user() # Get the user data created by the identity_handler

    authenticator=authenticator.with_scopes(["read:location"]), # Require some scopes to access the ressource
def get_user_location():
    user = get_authenticated_user()
    return locationService.get(user)


If you wish to use swagger, you will need to register the custom authenticators. This is needed by rebar to be able to convert them to the right swagger security definition. If you use the Cookie authentication, please note that swagger 2.0 does support this method of authentication. It will be registered as a Cookie header.

from flask_rebar_auth0 import register_authenticators


Project details

Download files

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

Source Distribution

flask-rebar-auth0-0.1.5.tar.gz (5.0 kB view hashes)

Uploaded source

Built Distribution

flask_rebar_auth0-0.1.5-py3-none-any.whl (6.7 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page