Invalid API key error is now in json format
This commit is contained in:
+3
-1
@@ -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"'}
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user