How to programmatically create a user using django_social_auth?

I am writing several test scripts for a django application that relies on django_social_auth to manage user authentication and login (only for facebook login).

I would like to get around the django_social_auth registration part - I already have some test users, and I get their authentication tokens before other tests.

I should not, technically, register my tested users again - for this test there should be enough existing, valid tokens.

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

(I have to add that some of the user data can be deleted from my database between their authentication and the point at which I run this test)

+4
source share
1 answer

I recently made a similar setup. You must override the default value of SOCIAL_AUTH_PIPELINE . I would recommend you write some handler and replace it in the pipeline. For more information, you can contact http://django-social-auth.readthedocs.org/en/latest/pipeline.html

My extended 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', ) 
+1
source

All Articles