mirror of
https://github.com/Tivix/django-rest-auth.git
synced 2024-12-02 13:53:43 +03:00
Merge pull request #85 from mimischi/patch-1
Return refresh_token and expires_in in SocialLoginSerializer
This commit is contained in:
commit
05296dec44
|
@ -79,6 +79,7 @@ class SocialLoginSerializer(serializers.Serializer):
|
||||||
# Case 1: We received the access_token
|
# Case 1: We received the access_token
|
||||||
if attrs.get('access_token'):
|
if attrs.get('access_token'):
|
||||||
access_token = attrs.get('access_token')
|
access_token = attrs.get('access_token')
|
||||||
|
tokens_to_parse = {'access_token': access_token}
|
||||||
|
|
||||||
# Case 2: We received the authorization code
|
# Case 2: We received the authorization code
|
||||||
elif attrs.get('code'):
|
elif attrs.get('code'):
|
||||||
|
@ -109,12 +110,17 @@ class SocialLoginSerializer(serializers.Serializer):
|
||||||
)
|
)
|
||||||
token = client.get_access_token(code)
|
token = client.get_access_token(code)
|
||||||
access_token = token['access_token']
|
access_token = token['access_token']
|
||||||
|
tokens_to_parse = {'access_token': access_token}
|
||||||
|
|
||||||
|
# If available we add additional data to the dictionary
|
||||||
|
for key in ["refresh_token", adapter.expires_in_key]:
|
||||||
|
if key in token:
|
||||||
|
tokens_to_parse[key] = token[key]
|
||||||
else:
|
else:
|
||||||
raise serializers.ValidationError(
|
raise serializers.ValidationError(
|
||||||
_("Incorrect input. access_token or code is required."))
|
_("Incorrect input. access_token or code is required."))
|
||||||
|
|
||||||
social_token = adapter.parse_token({'access_token': access_token})
|
social_token = adapter.parse_token(tokens_to_parse)
|
||||||
social_token.app = app
|
social_token.app = app
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user