views.py 676 B

12345678910111213141516171819
  1. from django.shortcuts import render
  2. from rest_framework import viewsets
  3. from django.utils.decorators import method_decorator
  4. from django.views.decorators.csrf import csrf_exempt
  5. from .models import OAuth
  6. from .serializers import OAuthSerializer
  7. # Create your views here.
  8. from allauth.socialaccount.providers.google.views import GoogleOAuth2Adapter
  9. from rest_auth.registration.views import SocialLoginView
  10. @method_decorator(csrf_exempt, name='dispatch')
  11. class GoogleLogin(SocialLoginView):
  12. adapter_class = GoogleOAuth2Adapter
  13. class OAuthViewSet(viewsets.ModelViewSet):
  14. queryset = OAuth.objects.all()
  15. serializer_class = OAuthSerializer
  16. model_class = OAuth