I'm new to django and social auth.
I'm trying to make a site where people login (with google) and post stuff. I was using python-social-auth and the user was getting logged in just fine. Then I wanted to use DRF and it needed it's own authentication so I looking at django-rest-framework-social-auth, but can't understand how to use it. I followed the instructions and changed my settings.py and the user is still getting authenticated. But not with the DRF ( post requests respond with 401 error). To my understanding I need to send a token to the client which he has to include in subsequent requests.
I have the following doubts:
In https://github.com/PhilipGarnero/django-rest-framework-social-oauth2, there is a curl request for getting a token(i presume it is the access_token), where should I make that request? Because it includes the client secret, I think it can't be in the browser? ( I still tried the curl request and it shows 'invalid client') Also I get the access token directly in the python-social-auth pipeline. How do I convert that to a user access token(in the backend)?
There is a section on the social authentication class, but I can't figure out how to use it.
my view:
class WantedViewSet(viewsets.ModelViewSet):
queryset = models.Wanted.objects.all()
serializer_class = serializers.WantedSerializer
permission_classes = (permissions.IsAuthenticatedOrReadOnly,)
authentication_classes=(SocialAuthentication,OAuth2Authentication,)
def perform_create(self, serializer):
serializer.save(owner=self.request.user)
settings:
REST_FRAMEWORK = {
'DEFAULT_RENDERER_CLASSES': (
'rest_framework.renderers.JSONRenderer',
),
'DEFAULT_AUTHENTICATION_CLASSES': (
'oauth2_provider.ext.rest_framework.OAuth2Authentication',
'rest_framework_social_oauth2.authentication.SocialAuthentication',
),
'DEFAULT_PERMISSION_CLASSES': (
'rest_framework.permissions.IsAuthenticatedOrReadOnly',
),
}