Invalid API key error is now in json format
This commit is contained in:
+3
-1
@@ -1,4 +1,5 @@
|
|||||||
# coding=UTF-8
|
# coding=UTF-8
|
||||||
|
import json
|
||||||
from flask import request, current_app, Response
|
from flask import request, current_app, Response
|
||||||
import unidecode
|
import unidecode
|
||||||
import re
|
import re
|
||||||
@@ -9,8 +10,9 @@ def check_api_key():
|
|||||||
return
|
return
|
||||||
auth = request.authorization
|
auth = request.authorization
|
||||||
if not auth or not auth.username in api_keys:
|
if not auth or not auth.username in api_keys:
|
||||||
|
response = json.dumps({'status': 401, 'message': 'No valid API key provided'})
|
||||||
return Response(
|
return Response(
|
||||||
'No valid API key provided', 401,
|
response, 401,
|
||||||
{'WWW-Authenticate': 'Basic realm="Login Required"'}
|
{'WWW-Authenticate': 'Basic realm="Login Required"'}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user