X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/6d42bc478e3d1bd90eb294464748c21e4de0fc63..972f33fb2d98a9ff59c931ac6a8a82def7cea6fe:/src/api/views.py?ds=sidebyside diff --git a/src/api/views.py b/src/api/views.py index 69f9b8b03..be1491b6f 100644 --- a/src/api/views.py +++ b/src/api/views.py @@ -10,13 +10,12 @@ from django.views.generic.base import View from oauthlib.common import urlencode from oauthlib.oauth1 import RequestTokenEndpoint, AccessTokenEndpoint from oauthlib.oauth1 import AuthorizationEndpoint, OAuth1Error -from api.models import KEY_SIZE, SECRET_SIZE from rest_framework.permissions import IsAuthenticated from rest_framework.response import Response from rest_framework.views import APIView -from rest_framework.generics import ListAPIView, RetrieveAPIView, get_object_or_404 +from rest_framework.generics import RetrieveAPIView, get_object_or_404 from catalogue.models import Book -from .models import BookUserData +from .models import BookUserData, KEY_SIZE, SECRET_SIZE from . import serializers from .request_validator import PistonRequestValidator from .utils import oauthlib_request, oauthlib_response, vary_on_auth @@ -76,7 +75,7 @@ def oauth_user_auth(request): realms, credentials = endpoint.get_realms_and_credentials( **oauthlib_request(request)) except OAuth1Error as e: - return HttpResponse(e.message, status=400) + return HttpResponse(str(e), status=400) callback = request.GET.get('oauth_callback') form = OAuthAuthenticationForm(initial={ @@ -86,7 +85,7 @@ def oauth_user_auth(request): return render(request, 'oauth/authorize_token.html', {'form': form}) - elif request.method == "POST": + if request.method == "POST": try: response = oauthlib_response( endpoint.create_authorization_response(