set token in session before making oauth request

This commit is contained in:
Matthew Scragg 2015-11-13 17:03:58 -06:00
parent 7178a6190e
commit c3ac176c15
2 changed files with 4 additions and 4 deletions

View file

@ -111,9 +111,7 @@ class User(BaseUser):
return users.get(user_id)
@staticmethod
def auth(provider, data, resp):
oauth_token = resp.get(User.get_provider_value(provider, 'token_name'))
session[provider + "_token"] = (oauth_token, '')
def auth(provider, data, oauth_token):
field_map = providers.get(provider).get('field_map')
if not field_map:
raise NotImplementedError

View file

@ -29,9 +29,11 @@ def callback(provider):
flash('Access denied: %s' % e.message)
return redirect(next_url)
oauth_token = resp.get(User.get_provider_value(provider, 'token_name'))
session[provider + "_token"] = (oauth_token, '')
profile = User.get_provider_value(provider, 'profile')
data = remote_app.get(profile) if profile else resp
User.auth(provider, data, resp)
User.auth(provider, data, oauth_token)
return redirect(next_url)