Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python社交身份验证,扩展断开连接管道_Python_Django_Python Social Auth - Fatal编程技术网

Python社交身份验证,扩展断开连接管道

Python社交身份验证,扩展断开连接管道,python,django,python-social-auth,Python,Django,Python Social Auth,我有一个用户配置文件表,它有fb_id,tw_id。所以我正在检查用户是否连接了他们的社交帐户。当用户断开其中一个帐户时,我需要更新这些列 SOCIAL_AUTH_DISCONNECT_PIPELINE = ( 'social.pipeline.disconnect.allowed_to_disconnect', 'social.pipeline.disconnect.get_entries', 'social.pipeline.disconnect.revoke_tok

我有一个用户配置文件表,它有fb_id,tw_id。所以我正在检查用户是否连接了他们的社交帐户。当用户断开其中一个帐户时,我需要更新这些列

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',
)
因此,我在我的个人资料应用程序中添加了一个名为disconnect的函数

当我尝试断开帐户连接时,出现以下错误:

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)
这是我第一次使用python\u social\u auth,任何帮助都将不胜感激。

试试这个

SOCIAL_AUTH_DISCONNECT_PIPELINE = (
    'social.pipeline.disconnect.allowed_to_disconnect',
    'social.pipeline.disconnect.get_entries',
    'social.pipeline.disconnect.revoke_tokens',
    # 'social.pipeline.disconnect.disconnect',  # comment
    'profiles.utils.custom_pipeline',
)
自定义管道.py

def disconnect(strategy, entries, user_storage, *args, **kwargs):        
    for entry in entries:
        user_storage.disconnect(entry)
    backend = kwargs.get('name')

    profile=Profiles.objects.get(user=entries[0].user)
    if backend == 'facebook':
        profile.fb_id = ''
    elif backend == 'twitter':
        profile.tw_id = ''
    elif backend == 'instagram':
        new_profile.in_id = ''
    profile.save()
最好的

我解决了这个问题:

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',
)
并将功能修改为:

def disconnect(strategy, entries, *args, **kwargs):
    backend = kwargs.get('name')

    profile=Profiles.objects.get(user=entries[0].user)
    if backend == 'facebook':
        profile.fb_id = False
    elif backend == 'twitter':
        profile.tw_id = False
    elif backend == 'instagram':
        new_profile.in_id = False
    profile.save()

现在它工作得很好。

嗨,谢谢你的回答。我尝试了您的解决方案,但出现了一个新错误,它说:列表索引超出范围如果您使用social auth自己的断开连接并从args和for块中删除用户存储,此解决方案将有效。
def disconnect(strategy, entries, *args, **kwargs):
    backend = kwargs.get('name')

    profile=Profiles.objects.get(user=entries[0].user)
    if backend == 'facebook':
        profile.fb_id = False
    elif backend == 'twitter':
        profile.tw_id = False
    elif backend == 'instagram':
        new_profile.in_id = False
    profile.save()