Python Social Auth NotAllowedToDisconnect at /disconnect/facebook/1/

django, facebook, python, python-social-auth

Solution

Provide a separate logout action to separate logout and disconnect.

from django.contrib.auth import logout as auth_logout

def logout(request):
    """Logs out user"""
    auth_logout(request)
    return render_to_response('home.html', {}, RequestContext(request))

Refer to the Django example app for a full example.

In your disconnect pipeline you have `social.pipeline.disconnect.allowed_to_disconnect`. This will verify that the user has a valid way to login after the current login method has been disconnected. This is handle by allowed_to_disconnect.

To allow the user to diconnect and to avoid the `NotAllowedToDisconnect` remove the `social.pipeline.disconnect.allowed_to_disconnect` from your `SOCIAL_AUTH_DISCONNECT_PIPELINE`.

Problem

I'm trying to use logout with Python Social Auth in a Django app, but I'm getting ``` NotAllowedToDisconnect at /disconnect/facebook/1/ ``` These are my settings: ``` SOCIAL_AUTH_PIPELINE = ( 'social.pipeline.social_auth.social_details', 'social.pipeline.social_auth.social_uid', 'social.pipeline.social_auth.auth_allowed', 'social.pipeline.social_auth.social_user', 'social.pipeline.user.get_username', 'social.pipeline.mail.mail_validation', 'social.pipeline.user.create_user', 'social.pipeline.social_auth.associate_user', 'social.pipeline.social_auth.load_extra_data', 'social.pipeline.user.user_details' ) SOCIAL_AUTH_DISCONNECT_PIPELINE = ( 'social.pipeline.disconnect.allowed_to_disconnect', 'social.pipeline.disconnect.get_entries', 'social.pipeline.disconnect.revoke_tokens', 'social.pipeline.disconnect.disconnect' ) ``` And this is the code I'm using on templates ``` {{ assoc.provider }} (<a href="{% url 'social:disconnect_individual' assoc.provider assoc.id %}" class="disconnect">Disconnect </a>) ```

Original source