0

The screenshot of the error

I have used django package social_auth to implement facebook login on my website. I am able to log in correctly and get all the data. But I am not able to logout.

I am not using django.user.login and logout. I am using socialauth_begin and socialauth_disconnect

I am able to login, go in the social auth pipeline, get the necessary information, but I am not able to logout. What is the fix to this problem?

When I click on "Logout" in Logout I get the following error

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

The settings I have is this:

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/'

Please Help. Thanks

The code I used to Login was:

<a href="{% url "socialauth_begin" "facebook" %}" class="btn"><h3 style="color:white">Connect via Facebook</h3></a>
Pratik Poddar
  • 1,353
  • 3
  • 18
  • 36
  • 1
    Disconnect is not the same than logout, disconnect instead will remove the association with the social account and the current user. Next time the user tries to login with the Facebook acccount, a new user instance will be created in your app. You should use the logout mechanism builtin in Django (or implement a similar one). – omab Aug 23 '13 at 19:36

1 Answers1

0

I just have the same problem but with twitter.

This error is generated because the user has not another way to connect/disconnect from the system, and the API in some way think it would be dangerous.

How I resolve the problem was calling a custom logout form like in the example:

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

lowfill
  • 1
  • 1