Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion rest_auth/registration/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from allauth.socialaccount.helpers import complete_social_login
from allauth.socialaccount.models import SocialAccount
from allauth.socialaccount.providers.base import AuthProcess
from allauth.socialaccount.providers.oauth2.client import OAuth2Error
except ImportError:
raise ImportError("allauth needs to be added to INSTALLED_APPS.")

Expand Down Expand Up @@ -108,7 +109,10 @@ def validate(self, attrs):
self.callback_url,
scope
)
token = client.get_access_token(code)
try:
token = client.get_access_token(code)
except OAuth2Error as e:
raise serializers.ValidationError({'code': e})
access_token = token['access_token']

else:
Expand Down