Skip to content

Commit

Permalink
Merge a28539e into b0b6e11
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonDatsik committed Feb 2, 2020
2 parents b0b6e11 + a28539e commit 95dbaf4
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions rest_social_auth/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
import warnings

try:
from urllib.parse import urljoin, urlparse # python 3x
from urllib.parse import urljoin, urlencode, urlparse # python 3x
except ImportError:
from urlparse import urljoin, urlparse # python 2x
from urllib import urlencode # python 2x
from urlparse import urljoin, urlparse

from django.conf import settings
from django.http import HttpResponse
Expand Down Expand Up @@ -163,6 +164,19 @@ def get_object(self):
# session to do it.
self.request.backend.REDIRECT_STATE = False
self.request.backend.STATE_PARAMETER = False

if self.oauth_v1():
# Oauth1 uses sessions, in case of token authentication session store will be empty
backend = self.request.backend
session_token_name = backend.name + backend.UNATHORIZED_TOKEN_SUFIX
if not self.request.session.exists(session_token_name):
self.request.session[session_token_name] = [
urlencode({
backend.OAUTH_TOKEN_PARAMETER_NAME: backend.data.get(backend.OAUTH_TOKEN_PARAMETER_NAME),
'oauth_token_secret': backend.data.get('oauth_token_secret')
})
]

user = self.request.backend.complete(user=user)
return user

Expand Down

0 comments on commit 95dbaf4

Please sign in to comment.