Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Github access_token never stored #344

Closed
LeonardoGentile opened this issue Aug 7, 2014 · 2 comments
Closed

Github access_token never stored #344

LeonardoGentile opened this issue Aug 7, 2014 · 2 comments

Comments

@LeonardoGentile
Copy link

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

@omab
Copy link
Owner

omab commented Aug 9, 2014

@LeonardoGentile, that shouldn't be necessary, the base backend takes care of that for you https://github.com/omab/python-social-auth/blob/master/social/backends/oauth.py#L182-L186

I confirm that access_token is stored in extra_data when using the default flow.

@webjunkie
Copy link
Contributor

I think this is similar to #416

@omab omab closed this as completed in 498bc59 Apr 4, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants