I have a user profile table and it has fb_id, tw_id. So I am checking if users connected their social accounts. I need to update these columns when user disconnects one of their accounts.
SOCIAL_AUTH_DISCONNECT_PIPELINE = (
'social.pipeline.disconnect.allowed_to_disconnect',
'social.pipeline.disconnect.get_entries',
'social.pipeline.disconnect.revoke_tokens',
'social.pipeline.disconnect.disconnect',
'profiles.utils.disconnect',
)
So I added a function named disconnect in my profile app as it refers here.
def disconnect(backend, user, response, *args, **kwargs):
if Profiles.objects.filter(user=user).exists():
if backend.name == 'facebook':
profile=Profiles.objects.get(user=user)
profile.fb_id = ''
profile.save()
if backend.name == 'twitter':
profile=Profiles.objects.get(user=user)
profile.tw_id = ''
profile.save()
if backend.name == 'instagram':
profile=Profiles.objects.get(user=user)
new_profile.in_id = ''
profile.save()
When I try to disconnect my account I get this error:
TypeError at /disconnect/facebook/
disconnect() takes at least 3 arguments (2 given)
Request Method: POST
Request URL: /disconnect/facebook/
Django Version: 1.8.2
Exception Type: TypeError
Exception Value:
disconnect() takes at least 3 arguments (2 given)
This is first time I use python_social_auth, any help will be appreciated.
I solved the problem:
And revised the function as this:
Now it works perfectly.