X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/ea221b2bc448ce22dfda4f1ead2968fa7de31771..355e42e2b2244470ac6a5b9ad056e4a3f38f838c:/src/api/drf_auth.py diff --git a/src/api/drf_auth.py b/src/api/drf_auth.py index ca6a49188..893f06610 100644 --- a/src/api/drf_auth.py +++ b/src/api/drf_auth.py @@ -5,6 +5,7 @@ from oauthlib.oauth1 import ResourceEndpoint from rest_framework.authentication import BaseAuthentication from .request_validator import PistonRequestValidator +from .utils import oauthlib_request class PistonOAuthAuthentication(BaseAuthentication): @@ -17,13 +18,7 @@ class PistonOAuthAuthentication(BaseAuthentication): def authenticate(self, request): v, r = self.provider.validate_protected_resource_request( - request.build_absolute_uri(), - http_method=request.method, - body=request.body, - headers={ - "Authorization": request.META['HTTP_AUTHORIZATION'], - "Content-Type": request.content_type, - } if 'HTTP_AUTHORIZATION' in request.META else None + **oauthlib_request(request) ) if v: return r.token.user, r.token