Comments (7)
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.
My current fix:
Inject a step into python-social-auth:
SOCIAL_AUTH_PIPELINE = (
'social.pipeline.social_auth.social_details',
'social.pipeline.social_auth.social_uid',
'social.pipeline.social_auth.auth_allowed',
'social.pipeline.social_auth.social_user',
'social.pipeline.user.get_username',
'social.pipeline.user.create_user',
'social.pipeline.social_auth.associate_user',
'path.to.your.view.save_oauth',
'social.pipeline.social_auth.load_extra_data',
'social.pipeline.user.user_details',
)
As this step occurs after associate_user, we have the newly created user model as well as the token available to us in the request.
@partial
def save_oauth(strategy, details, user=False, *args, **kwargs):
request = kwargs.get('request', None)
if user and request:
access_token = request.get('token', None)
social = user.social_auth.get(provider='github')
social.extra_data['access_token'] = access_token
social.save()
return { 'is_new': False, 'user': user }
return { 'is_new': True, 'user': None }
from django-rest-framework-social-oauth2.
This is not an issue actually. It comes from python-social-auth. Every backend has a different behavior and the user must modify the pipeline according to his needs. This is the expected behavior and this is exactly what you are doing :)
from django-rest-framework-social-oauth2.
The thing is....this wasn't a problem before. I was already using python-social-auth and it was saving the token on the user just fine.
It was only when I started using django-rest-framework-social-oauth2 that I had to manually set it as above.
from django-rest-framework-social-oauth2.
Well, I don't have time to investigate this as this is not blocking but if you find where this comes from tell me and I'll fix it.
You can begin here and follow here. See if the access token is present, if not track the starting point.
from django-rest-framework-social-oauth2.
Thats fine. Thanks for pointing me in the right direction. If I figure out the root of it, I'll open a PR with whichever project needs the fix.
At least for now there is relatively straightforward workaround.
from django-rest-framework-social-oauth2.
I've confirmed that this is an issue with python-social-auth. Given that it used to work for me, I assume it has to do with version number changes I made when I started using django-rest-framework-social-oauth2. Will continue to investigate and may open an issue with python-social-auth.
This ticket should be closed as far as I'm concerned.
from django-rest-framework-social-oauth2.
Thank you for your investigations.
from django-rest-framework-social-oauth2.
Related Issues (20)
- Documentation is out of sync HOT 1
- Django rest framework social oauth2 causing unexpected error with Djongo for mongoDB conversion of django app HOT 2
- How can I access "access tokens" of registered users in Backend ? HOT 1
- installing to docker container HOT 1
- Getting error while creating new application. HOT 1
- AppleIdAuth not working HOT 6
- url oauth callback for twitter HOT 1
- Fix simple typo: internaly -> internally HOT 1
- How can I revoke the refresh tokens?
- Your credentials aren't allowed HOT 1
- Refresh Token Error HOT 1
- unsupported_grant_type when trying to refresh token HOT 1
- custom backend not working with convert token api
- Question HOT 10
- Quick fix to enable this package to work with Django 4 and the older versions HOT 1
- why im getting invalid client error while trying to post in postman HOT 2
- I am getting a 401 Error (Unauthorized) and Uncaught (in promise) Error. Same is working fine on PostMan
- How to associate an existing user with multiple social accounts (different emails)? [DRF_SOCIAL_OAUTH2]
- cannot import name 'url' from 'django.conf.urls' HOT 5
- Client ID Error HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-rest-framework-social-oauth2.