Skip to content

Instantly share code, notes, and snippets.

@berinhard
Created May 8, 2012 02:46
Show Gist options
  • Save berinhard/2632187 to your computer and use it in GitHub Desktop.
Save berinhard/2632187 to your computer and use it in GitHub Desktop.
django-social-auth-plus
########################################
########## MEU_PIPELINE.PY #############
########################################
def populate_user_profile(*args, **kwargs):
response = kwargs['response']
user = kwargs['user']
month, day, year = [int(x) for x in response['birthday'].split('/')]
kwargs = {
'user': user,
'hometown': response['hometown']['name'],
'birthday': date(year, month, day),
}
try:
profile = user.get_profile()
profile.hometown = kwargs['hometown']
profile.birthday = kwargs['birthday']
profile.save()
except Exception:
Profile.objects.create(**kwargs)
########################################
############ SETTINGS.PY ###############
########################################
SOCIAL_AUTH_PIPELINE = (
'social_auth.backends.pipeline.social.social_auth_user',
'social_auth.backends.pipeline.associate.associate_by_email',
'social_auth.backends.pipeline.user.get_username',
'social_auth.backends.pipeline.user.create_user',
'social_auth.backends.pipeline.social.associate_user',
'meu_pipeline.populate_user_profile',
)
#Facebook keys
FACEBOOK_EXTENDED_PERMISSIONS = ['email', 'user_birthday', 'user_hometown']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment