mirror of
https://github.com/Tivix/django-rest-auth.git
synced 2024-11-28 20:13:43 +03:00
Handled invalid auth_code parsing error
This commit is contained in:
parent
624ad01afb
commit
7c30c9df29
|
@ -11,6 +11,7 @@ try:
|
||||||
from allauth.socialaccount.helpers import complete_social_login
|
from allauth.socialaccount.helpers import complete_social_login
|
||||||
from allauth.socialaccount.models import SocialAccount
|
from allauth.socialaccount.models import SocialAccount
|
||||||
from allauth.socialaccount.providers.base import AuthProcess
|
from allauth.socialaccount.providers.base import AuthProcess
|
||||||
|
from allauth.socialaccount.providers.oauth2.client import OAuth2Error
|
||||||
except ImportError:
|
except ImportError:
|
||||||
raise ImportError("allauth needs to be added to INSTALLED_APPS.")
|
raise ImportError("allauth needs to be added to INSTALLED_APPS.")
|
||||||
|
|
||||||
|
@ -108,7 +109,10 @@ class SocialLoginSerializer(serializers.Serializer):
|
||||||
self.callback_url,
|
self.callback_url,
|
||||||
scope
|
scope
|
||||||
)
|
)
|
||||||
|
try:
|
||||||
token = client.get_access_token(code)
|
token = client.get_access_token(code)
|
||||||
|
except OAuth2Error as e:
|
||||||
|
raise serializers.ValidationError({'code': e})
|
||||||
access_token = token['access_token']
|
access_token = token['access_token']
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user