From 4b593c8cbef6b16fb08b0baef1defaceec0baefc Mon Sep 17 00:00:00 2001 From: Martin Date: Thu, 30 Jun 2016 17:10:07 +0200 Subject: [PATCH] Invalid API key error is now in json format --- api/helpers.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/api/helpers.py b/api/helpers.py index 6965c55..4441b78 100644 --- a/api/helpers.py +++ b/api/helpers.py @@ -1,4 +1,5 @@ # coding=UTF-8 +import json from flask import request, current_app, Response import unidecode import re @@ -9,8 +10,9 @@ def check_api_key(): return auth = request.authorization if not auth or not auth.username in api_keys: + response = json.dumps({'status': 401, 'message': 'No valid API key provided'}) return Response( - 'No valid API key provided', 401, + response, 401, {'WWW-Authenticate': 'Basic realm="Login Required"'} )