Created
July 31, 2012 17:22
-
-
Save percyperez/3218699 to your computer and use it in GitHub Desktop.
Get user avatar url from Twitter, FB via django-social-auth
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_avatar_url(request, backend, response, *args, **kwargs): | |
"""Pipeline to get user avatar from Twitter/FB via django-social-auth""" | |
avatar_url = '' | |
if isinstance(backend, FacebookBackend): | |
avatar_url = 'http://graph.facebook.com/%s/picture?type=large' \ | |
% response['id'] | |
elif isinstance(backend, TwitterBackend): | |
avatar_url = response.get('profile_image_url', '') | |
request.session['avatar_url'] = avatar_url | |
return | |
# base.py | |
SOCIAL_AUTH_PIPELINE = ( | |
'social_auth.backends.pipeline.social.social_auth_user', | |
'more_social_auth_pipelines_here', | |
'path_to_get_avatar_url_pipeline' | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's giving me that social_auth isn't defined, I am using social_core.backends , please help