From 4599adf92b841c518cadb89b1fce8e015d214fa7 Mon Sep 17 00:00:00 2001 From: Ankit Popli Date: Fri, 25 Nov 2016 20:33:43 +0530 Subject: [PATCH] fix: social login using auth code flow 'access_token' in attrs always returns True, we need to check whether the token is empty or not --- rest_auth/registration/serializers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rest_auth/registration/serializers.py b/rest_auth/registration/serializers.py index d02297e..681dbd9 100644 --- a/rest_auth/registration/serializers.py +++ b/rest_auth/registration/serializers.py @@ -63,11 +63,11 @@ class SocialLoginSerializer(serializers.Serializer): # http://stackoverflow.com/questions/8666316/facebook-oauth-2-0-code-and-token # Case 1: We received the access_token - if 'access_token' in attrs: + if 'access_token' in attrs and attrs.get('access_token'): access_token = attrs.get('access_token') # Case 2: We received the authorization code - elif 'code' in attrs: + elif 'code' in attrs and attrs.get('code'): self.callback_url = getattr(view, 'callback_url', None) self.client_class = getattr(view, 'client_class', None)