Open HabibUllahKhanBarakzai opened 3 years ago
Hi, I had a similar issue I simply added a pipeline in my settings.py file, for example mine is:
SOCIAL_AUTH_PIPELINE = (
'social_core.pipeline.social_auth.social_details',
'social_core.pipeline.social_auth.social_uid',
'social_core.pipeline.social_auth.social_user',
'social_core.pipeline.user.get_username',
'social_core.pipeline.social_auth.associate_by_email',
'social_core.pipeline.user.create_user',
'social_core.pipeline.social_auth.associate_user',
'social_core.pipeline.social_auth.load_extra_data',
'social_core.pipeline.user.user_details',
)
in that way you force an existing user not to be created and moreover associate an existing one to the converted token; the executed code is then social_core.pipeline.user.py:
def create_user(strategy, details, backend, user=None, *args, **kwargs):
if user:
return {'is_new': False}
fields = dict((name, kwargs.get(name, details.get(name)))
for name in backend.setting('USER_FIELDS', USER_FIELDS))
if not fields:
return
return {
'is_new': True,
'user': strategy.create_user(**fields)
}
Hi all.
My team and I are constantly using this framework and it seems it has died out there. I contacted the owner by email asking if he would add some of us as maintainers so we could continue to improve it. However we didn't get a response.
I am publishing the project under my profile and we are going to continue to invest time in it.
So I would like to gently ask you to contribute to this project on: https://github.com/wagnerdelima/drf-social-oauth2
Thank you for understanding.
@carbogninalberto > SOCIAL_AUTH_PIPELINE itself not creating a new user do i need to customize create_user function also as i mentioned?
I cannot recall the details of what I have done, but I don't think you need to customize the create_user function, but add the social_core.pipeline.user.create_user
right after the social_core.pipeline.social_auth.associate_by_email
. By the way, I kindly suggest you migrate to the project linked by @wagnerdelima because this one it's not supported anymore.
Hi, I had a similar issue I simply added a pipeline in my settings.py file, for example mine is:
SOCIAL_AUTH_PIPELINE = ( 'social_core.pipeline.social_auth.social_details', 'social_core.pipeline.social_auth.social_uid', 'social_core.pipeline.social_auth.social_user', 'social_core.pipeline.user.get_username', 'social_core.pipeline.social_auth.associate_by_email', 'social_core.pipeline.user.create_user', 'social_core.pipeline.social_auth.associate_user', 'social_core.pipeline.social_auth.load_extra_data', 'social_core.pipeline.user.user_details', )
in that way you force an existing user not to be created and moreover associate an existing one to the converted token; the executed code is then social_core.pipeline.user.py:
def create_user(strategy, details, backend, user=None, *args, **kwargs): if user: return {'is_new': False} fields = dict((name, kwargs.get(name, details.get(name))) for name in backend.setting('USER_FIELDS', USER_FIELDS)) if not fields: return return { 'is_new': True, 'user': strategy.create_user(**fields) }
This Works for me
Hy, I am using django-rest-social-oauth2, and I need to handle the exceptional cases in which existing user wants to signin from facebook, so the current flow is that if the email is similar, it will create a new account by adding a random string to username when signing in from social login,
What I want to do is to associate the existing user account with the social login account, or may be not allow social login on existing user email, can you guide me on how I can achieve that.
Thanks