Skip to content

Instantly share code, notes, and snippets.

@JoabMendes
Created July 30, 2016 16:20
Show Gist options
  • Save JoabMendes/c220228bc83c1f2bd8860a63530c293e to your computer and use it in GitHub Desktop.
Save JoabMendes/c220228bc83c1f2bd8860a63530c293e to your computer and use it in GitHub Desktop.
Geting the user on view with django-rest-framework-social-oauth2
#Here is example 1
def get(self, request, format=None):
user = request.user
#....
#Here is the way I like to do (Verifying if the request is authenticated)
def get(self, request, format=None):
if request.auth:
user = request.user
#...
else:
return Response(status=status.HTTP_400_BAD_REQUEST)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment