# HG changeset patch # User durandn # Date 1459508176 -7200 # Node ID 425a2f1e08ea2d043ab758c590f9341897c364a8 # Parent 67b76cf4469e8f0672470b11cd1727a6de2322ac added error handling if token validation response is not a valid JSON string diff -r 67b76cf4469e -r 425a2f1e08ea server/src/metaeducation/auth.py --- a/server/src/metaeducation/auth.py Fri Apr 01 11:46:27 2016 +0200 +++ b/server/src/metaeducation/auth.py Fri Apr 01 12:56:16 2016 +0200 @@ -42,7 +42,15 @@ if token_validate_response.status_code != 200: logger.warning("CLIENT CREDENTIAL AUTH: Validation service didn't response with 200, there may be a problem") return - validate_response_json = json.loads(token_validate_response.text) + + try: + validate_response_json = json.loads(token_validate_response.text) + except json.JSONDecodeError as decode_error: + logger.warning("CLIENT CREDENTIAL AUTH: Token validate response was not a JSON!") + logger.warning("CLIENT CREDENTIAL AUTH: Tried to decode: %r", decode_error.doc) + logger.warning("CLIENT CREDENTIAL AUTH: Error message is %r", decode_error.msg) + return + # Response json validation if "access_token" not in validate_response_json.keys():