{"action":"created","issue":{"url":"https://api.github.com/repos/PhilipGarnero/django-rest-framework-social-oauth2/issues/27","labels_url":"https://api.github.com/repos/PhilipGarnero/django-rest-framework-social-oauth2/issues/27/labels{/name}","comments_url":"https://api.github.com/repos/PhilipGarnero/django-rest-framework-social-oauth2/issues/27/comments","events_url":"https://api.github.com/repos/PhilipGarnero/django-rest-framework-social-oauth2/issues/27/events","html_url":"https://github.com/PhilipGarnero/django-rest-framework-social-oauth2/issues/27","id":117596571,"number":27,"title":"Missing access_token in extra_data","user":{"login":"oudeismetis","id":444070,"avatar_url":"https://avatars.githubusercontent.com/u/444070?v=3","gravatar_id":"","url":"https://api.github.com/users/oudeismetis","html_url":"https://github.com/oudeismetis","followers_url":"https://api.github.com/users/oudeismetis/followers","following_url":"https://api.github.com/users/oudeismetis/following{/other_user}","gists_url":"https://api.github.com/users/oudeismetis/gists{/gist_id}","starred_url":"https://api.github.com/users/oudeismetis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oudeismetis/subscriptions","organizations_url":"https://api.github.com/users/oudeismetis/orgs","repos_url":"https://api.github.com/users/oudeismetis/repos","events_url":"https://api.github.com/users/oudeismetis/events{/privacy}","received_events_url":"https://api.github.com/users/oudeismetis/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-11-18T14:20:21Z","updated_at":"2015-11-19T14:15:42Z","closed_at":null,"body":"The `user social auths` model created by `python-social-auth` has a json blog called `extra_data`. It contains info like the `username` and `access_token` from the provider.\r\nI'm using the github backend and previously had my own endpoint to authenticate the user myself and take action when provided an access token from github. In that scenario, `extra_data` would contain the `access_token` which could be used for making API calls to github from the backend.\r\n\r\nI have now switched to django-rest-framework-social-oauth2 and have noticed that the `access_token` is now null. `id` and `login` are still there and correct."},"comment":{"url":"https://api.github.com/repos/PhilipGarnero/django-rest-framework-social-oauth2/issues/comments/158069626","html_url":"https://github.com/PhilipGarnero/django-rest-framework-social-oauth2/issues/27#issuecomment-158069626","issue_url":"https://api.github.com/repos/PhilipGarnero/django-rest-framework-social-oauth2/issues/27","id":158069626,"user":{"login":"oudeismetis","id":444070,"avatar_url":"https://avatars.githubusercontent.com/u/444070?v=3","gravatar_id":"","url":"https://api.github.com/users/oudeismetis","html_url":"https://github.com/oudeismetis","followers_url":"https://api.github.com/users/oudeismetis/followers","following_url":"https://api.github.com/users/oudeismetis/following{/other_user}","gists_url":"https://api.github.com/users/oudeismetis/gists{/gist_id}","starred_url":"https://api.github.com/users/oudeismetis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oudeismetis/subscriptions","organizations_url":"https://api.github.com/users/oudeismetis/orgs","repos_url":"https://api.github.com/users/oudeismetis/repos","events_url":"https://api.github.com/users/oudeismetis/events{/privacy}","received_events_url":"https://api.github.com/users/oudeismetis/received_events","type":"User","site_admin":false},"created_at":"2015-11-19T14:15:42Z","updated_at":"2015-11-19T14:15:42Z","body":"I have a workaround for this issue which I'll detail below. I'm new to these libraries, so I'm having trouble figuring where the proper fix location would be. If anyone has an idea, let me know, I'm more than willing to fork, fix, test, and PR.\r\n\r\nMy current fix:\r\nInject a step into python-social-auth:\r\n```\r\nSOCIAL_AUTH_PIPELINE = (\r\n    'social.pipeline.social_auth.social_details',\r\n    'social.pipeline.social_auth.social_uid',\r\n    'social.pipeline.social_auth.auth_allowed',\r\n    'social.pipeline.social_auth.social_user',\r\n    'social.pipeline.user.get_username',\r\n    'social.pipeline.user.create_user',\r\n    'social.pipeline.social_auth.associate_user',\r\n    'path.to.your.view.save_oauth',\r\n    'social.pipeline.social_auth.load_extra_data',\r\n    'social.pipeline.user.user_details',\r\n)\r\n```\r\nAs this step occurs after associate_user, we have the newly created user model as well as the token available to us in the request.\r\n```\r\n@partial\r\ndef save_oauth(strategy, details, user=False, *args, **kwargs):\r\n    request = kwargs.get('request', None)\r\n    if user and request:\r\n        access_token = request.get('token', None)\r\n        social = user.social_auth.get(provider='github')\r\n        social.extra_data['access_token'] = access_token\r\n        social.save()\r\n        return { 'is_new': False, 'user': user }\r\n    return { 'is_new': True, 'user': None }\r\n```"}}