# Path: invenio_oauth2server/provider.py
# def get_user(email, password, *args, **kwargs):
# def get_token(access_token=None, refresh_token=None):
# def get_client(client_id):
# def save_token(token, request, *args, **kwargs):
# def login_oauth2_user(valid, oauth):
# 
# Path: invenio_oauth2server/proxies.py



import sys
from functools import wraps
from flask import abort, current_app, request, session
from flask_login import current_user
from six import reraise
from werkzeug.exceptions import Unauthorized
from .provider import oauth2
from .proxies import current_oauth2server
# -*- coding: utf-8 -*-
#
# This file is part of Invenio.
# Copyright (C) 2015-2018 CERN.
#
# Invenio is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.

"""Useful decorators for checking authentication and scopes."""





def require_api_auth(allow_anonymous=False):
    """Decorator to require API authentication using OAuth token.

    :param allow_anonymous: Allow access without OAuth token
        (default: ``False``).
    """
    def wrapper(f):
        """Wrap function with oauth require decorator."""

# Path: invenio_oauth2server/provider.py
# def get_user(email, password, *args, **kwargs):
# def get_token(access_token=None, refresh_token=None):
# def get_client(client_id):
# def save_token(token, request, *args, **kwargs):
# def login_oauth2_user(valid, oauth):
# 
# Path: invenio_oauth2server/proxies.py



# Path: invenio_oauth2server/decorators.py
import sys
from functools import wraps
from flask import abort, current_app, request, session
from flask_login import current_user
from six import reraise
from werkzeug.exceptions import Unauthorized
from .provider import oauth2
from .proxies import current_oauth2server

# -*- coding: utf-8 -*-
#
# This file is part of Invenio.
# Copyright (C) 2015-2018 CERN.
#
# Invenio is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.

"""Useful decorators for checking authentication and scopes."""





def require_api_auth(allow_anonymous=False):
    """Decorator to require API authentication using OAuth token.

    :param allow_anonymous: Allow access without OAuth token
        (default: ``False``).
    """
    def wrapper(f):
        """Wrap function with oauth require decorator."""

        f_oauth_required = oauth2.require_oauth()(f)