def _api_authentication(): """ Attempt API authentication on a per-request basis.""" secure_app_access = app.config.get('SECURE_APP_ACCESS', False) if not secure_app_access: grant_access_with_api_key(secure_app_access) # Handle forms request.body = request.form if (request.method == 'POST' and request.headers.get('Content-Type') == 'application/json' and request.data): try: request.body = get_json_multidict(request) except TypeError: abort(400)
def _api_authentication_with_api_key(): """ Allow API access with valid api_key.""" secure_app_access = current_app.config.get('SECURE_APP_ACCESS', False) if secure_app_access: grant_access_with_api_key(secure_app_access)