4

I'm writing some test scripts for a django application which relies on django_social_auth for managing user authentication and login (facebook login only).

I'd like to bypass the login portion of django_social_auth - I already have some test users, and I obtain their authentication tokens earlier through other tests.

I shouldn't, technically, need to log my test users in again - the existing, valid, tokens should be sufficient for this test.

How do I machine the django_social_auth system to use my existing copies of the auth tokens, bypassing the user login process?

(I should add that some of the users' data may have been removed from my database between their authentication and the point I run this test at)

blueberryfields
  • 45,910
  • 28
  • 89
  • 168
  • Why do you need a login from social auth if you already have the user logged in? – EsseTi Feb 07 '13 at 19:05
  • 1
    the best way is to look into the django_social_auth's source code exactly start from the views.py here https://github.com/omab/django-social-auth/blob/master/social_auth/views.py I think that the method auth_process and complete_process can be useful for you. – Mounir Feb 13 '13 at 13:31

1 Answers1

1

I have recently done the similar customization. You have to override the default SOCIAL_AUTH_PIPELINE. I would recommend you to write some handler and replace the same in the pipeline. For more details you can refer http://django-social-auth.readthedocs.org/en/latest/pipeline.html

My enhanced pipeline:

SOCIAL_AUTH_PIPELINE = (
                'social_auth.backends.pipeline.social.social_auth_user',
                # Removed by default since it can be a dangerouse behavior that
                # could lead to accounts take over.
                #'social_auth.backends.pipeline.associate.associate_by_email',
                'social_auth.backends.pipeline.user.get_username',
                #'social_auth.backends.pipeline.user.create_user',
                'myproject.custom.create_user',
                'social_auth.backends.pipeline.social.associate_user',
                #'social_auth.backends.pipeline.social.load_extra_data',
                'myproject.custom.load_extra_data',
                'social_auth.backends.pipeline.user.update_user_details',
           )
Siva Arunachalam
  • 7,582
  • 15
  • 79
  • 132