I'm not using the default web flow but calling the do_auth from my custom method:
user = backend.do_auth(access_token, ajax=True)
The problem is that GithubOAuth2 backend never stores the access_token in the extra_data field.
I came up extending the GithubOauth2 backend:
class GithubOAuth2Extented(GithubOAuth2):
"""docstring for GithubOAuth2Extented"""
# overriding parent method because it did not saved the access_token
def user_data(self, access_token, *args, **kwargs):
"""Loads user data from service"""
data = self._user_data(access_token)
if not data.get('email'):
try:
email = self._user_data(access_token, '/emails')[0]
except (HTTPError, IndexError, ValueError, TypeError):
email = ''
if isinstance(email, dict):
email = email.get('email', '')
data['email'] = email
# Added by me
data['access_token'] = access_token
return data
super(GithubOAuth2Extented, self).user_data()
Not sure if it is the best solution tough
I'm not using the default web flow but calling the
do_authfrom my custom method:The problem is that
GithubOAuth2backend never stores theaccess_tokenin theextra_datafield.I came up extending the
GithubOauth2backend:Not sure if it is the best solution tough