Created
July 30, 2016 16:20
-
-
Save 0xLuz/c220228bc83c1f2bd8860a63530c293e to your computer and use it in GitHub Desktop.
Geting the user on view with django-rest-framework-social-oauth2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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