From 995ef714e1e7cdfdf77f537132a4ea1e20a90272 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Mon, 30 Dec 2019 21:05:56 +0000 Subject: [PATCH 1/1] Request validation fix. --- src/api/request_validator.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/api/request_validator.py b/src/api/request_validator.py index 690d3e9bf..9a4be2da8 100644 --- a/src/api/request_validator.py +++ b/src/api/request_validator.py @@ -32,7 +32,17 @@ class PistonRequestValidator(RequestValidator): return request.token.secret def get_access_token_secret(self, client_key, token, request): - return request.token.secret + if request.token: + return request.token.secret + else: + try: + token = Token.objects.get( + token_type=Token.ACCESS, + consumer__key=client_key, + key=token + ) + except: return None + return token.secret def get_default_realms(self, client_key, request): return ['API'] -- 2.20.1