Add grammar to tags. Also: respect custom tag slugs on publishing.
[wolnelektury.git] / src / api / request_validator.py
index 2c16691..9a4be2d 100644 (file)
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
 #
@@ -33,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']