0

错误截图

我已经使用 django 包 social_auth 在我的网站上实现了 facebook 登录。我能够正确登录并获取所有数据。但我无法注销。

我没有使用 django.user.login 和注销。我正在使用 socialauth_begin 和 socialauth_disconnect

我能够登录,进入社交身份验证管道,获取必要的信息,但我无法注销。这个问题的解决方法是什么?

当我在注销中单击“注销”时,出现以下错误

NotAllowedToDisconnect at /tomonotomo/auth/disconnect/facebook/
No exception supplied
Request Method: GET
Request URL:    http://localhost:8000/tomonotomo/auth/disconnect/facebook/
Django Version: 1.5.1
Exception Type: NotAllowedToDisconnect
Exception Location: /tmp/guest-onyOH9/pratik/virtualenv-1.10/tomonotomo/local/lib/python2.7/site-packages/social_auth/backends/__init__.py in disconnect, line 435
Python Executable:  /tmp/guest-onyOH9/pratik/virtualenv-1.10/tomonotomo/bin/python2.7
Python Version: 2.7.3
Python Path:    
['/tmp/guest-onyOH9/pratik/tomonotomo_project',
 '/tmp/guest-onyOH9/Desktop/pycharm-2.7.3/helpers/pydev',
 '/tmp/guest-onyOH9/pratik/tomonotomo_project',
 '/tmp/guest-onyOH9/pratik/virtualenv-1.10/tomonotomo/lib/python2.7',
 '/tmp/guest-onyOH9/pratik/virtualenv-1.10/tomonotomo/lib/python2.7/plat-linux2',
 '/tmp/guest-onyOH9/pratik/virtualenv-1.10/tomonotomo/lib/python2.7/lib-tk',
 '/tmp/guest-onyOH9/pratik/virtualenv-1.10/tomonotomo/lib/python2.7/lib-old',
 '/tmp/guest-onyOH9/pratik/virtualenv-1.10/tomonotomo/lib/python2.7/lib-dynload',
 '/usr/lib/python2.7',
 '/usr/lib/python2.7/plat-linux2',
 '/usr/lib/python2.7/lib-tk',
 '/tmp/guest-onyOH9/pratik/virtualenv-1.10/tomonotomo/local/lib/python2.7/site-packages',
 '/tmp/guest-onyOH9/pratik/virtualenv-1.10/tomonotomo/lib/python2.7/site-packages']
Server time:    Sat, 10 Aug 2013 22:27:42 -0500

我的设置是这样的:

AUTHENTICATION_BACKENDS = (
    'social_auth.backends.facebook.FacebookBackend',
    'django.contrib.auth.backends.ModelBackend',
)

FACEBOOK_EXTENDED_PERMISSIONS= ['email', 'user_birthday']

SOCIAL_AUTH_PIPELINE = (
    'social_auth.backends.pipeline.social.social_auth_user',
    'social_auth.backends.pipeline.associate.associate_by_email',
    'social_auth.backends.pipeline.user.get_username',
    'social_auth.backends.pipeline.user.create_user',    

    'tomonotomo.social_auth_pipeline.create_custom_user',

    'social_auth.backends.pipeline.social.associate_user',
    'social_auth.backends.pipeline.user.update_user_details',
)

SOCIAL_AUTH_CREATE_USERS = True
SOCIAL_AUTH_FORCE_RANDOM_USERNAME = False
SOCIAL_AUTH_DEFAULT_USERNAME = 'socialauth_user'
SOCIAL_AUTH_ENABLED_BACKENDS = ('facebook',)
SOCIAL_AUTH_COMPLETE_URL_NAME = 'socialauth_complete'
SOCIAL_AUTH_ASSOCIATE_URL_NAME = 'socialauth_associate_complete'
SOCIAL_AUTH_ASSOCIATE_BY_EMAIL = True
SOCIAL_AUTH_ERROR_KEY = 'socialauth_error'
SOCIAL_AUTH_REDIRECT_IS_HTTPS = False

LOGIN_URL = '/tomonotomo/login/' 
LOGIN_REDIRECT_URL = '/tomonotomo/' 
LOGIN_ERROR_URL = '/tomonotomo/login-error/'

请帮忙。谢谢

我用来登录的代码是:

<a href="{% url "socialauth_begin" "facebook" %}" class="btn"><h3 style="color:white">Connect via Facebook</h3></a>
4

1 回答 1

0

我只是有同样的问题,但在推特上。

生成此错误是因为用户没有其他方式连接/断开系统,并且 API 在某种程度上认为这会很危险。

我如何解决问题是调用自定义注销表单,如示例中所示:

https://github.com/omab/django-social-auth/blob/master/example/app/views.py#L39

于 2013-08-23T12:28:13.937 回答