diff --git a/tastypie_oauth/authentication.py b/tastypie_oauth/authentication.py index 4f9af22..9b0fcdf 100644 --- a/tastypie_oauth/authentication.py +++ b/tastypie_oauth/authentication.py @@ -54,7 +54,10 @@ def is_authenticated(self, request, **kwargs): if not key and request.method == 'POST': if request.META.get('CONTENT_TYPE') == 'application/json': decoded_body = request.body.decode('utf8') - key = json.loads(decoded_body)['oauth_consumer_key'] + try: + key = json.loads(decoded_body)['oauth_consumer_key'] + except (ValueError, KeyError): + pass if not key: log.info('OAuth20Authentication. No consumer_key found.') return None @@ -75,6 +78,8 @@ def is_authenticated(self, request, **kwargs): log.exception("Error in OAuth20Authentication.") request.user = AnonymousUser() return False + except OAuthError: + return False except Exception: log.exception("Error in OAuth20Authentication.") return False