Logging out with django-social-auth

I am a little versed in django-social-auth using twitter authentication.

May I come in.

But, when I try to log out using django.contrib.auth.logout , it does not django.contrib.auth.logout out.

How to log out?

Thanks.

+8
django django-socialauth
source share
3 answers

Are you trying to exit the Django application or want to “forget” Twitter access? Typically, the twitter auth token is saved for easier login the next time the user wants to connect to Twitter, so the user does not need to “accept” access again.

Exit Django

If you just want to log out of the Django authorization system, it should be enough to use the django.contrib.auth.views.logout or create a custom logout view.

Social Out

To completely disable / disable a social account, you need to use the disconnect functions in social-auth. You can get the disconnect URL using the following template tag:

 {% url "socialauth_disconnect" "backend-name" %} 

For more information see http://django-social-auth.readthedocs.org/en/v0.7.22/configuration.html#linking-in-your-templates .

Confirmation Invitation

Since you have already allowed your application access to the OAuth provider, the auth provider will remember this solution. There are usually two ways to forcibly confirm this access:

  • Revoke access permission in the management console of your authorization provider (for example, deny access to the Twitter application).
  • Specify an optional OAuth argument that prompts an approval prompt. I'm not sure Twitter provides such a thing, but if you use Google OAuth2, you can simply add {'approval_prompt': 'force'} to the GOOGLE_OAUTH2_AUTH_EXTRA_ARGUMENTS setting.
+9
source share

Do you have a logout? You need to have a logout.

Example:

 from django.contrib.auth import logout def logout_view(request): logout(request) # Redirect to a success page. 
+5
source share

This answer is deprecated as django-social-auth now python-social-auth

See the new stack overflow answer here .

Read the docs here

+3
source share

All Articles