Custom python-social-auth Pipeline

Sometimes when you authenticate with a social service you need to do custom "stuff" in your code base beyond creating a user object. Learn how to get started simply adding a custom function do the python-social-auth pipeline.
Download HD Version next video: Django with Bash for Windows

resources

python-social-auth pipeline docs

demo/settings.py

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.user.create_user',
    'social.pipeline.social_auth.associate_user',
    'social.pipeline.social_auth.load_extra_data',
    'social.pipeline.user.user_details',
    'home.pipeline.save_profile',
)

home/pipeline.py

from .models import UserProfile


def save_profile(backend, user, response, *args, **kwargs):
    UserProfile.objects.create(
        user=user, website=response['user']['website'],
        instagram_username=response['user']['username'])
comments powered by Disqus