4

I'm using social_auth API for login using social account. Is there is any possibilities to invite friends via facebook, twitter, linkedin in social-auth. or any other way to invite friends from social account. Please share your ideas.

user
  • 675
  • 2
  • 10
  • 19
  • 4
    Yes, but, that's not what part of what django-social-auth does. The invite workflow varies across social networks, so AFAIK there's no way to do generic 'invite from social auth account', you'll need separate code paths for facebook, twitter, etc. See http://stackoverflow.com/questions/8864557/fetching-facebook-data-once-logged-in-using-django-social-auth – AdamKG Aug 07 '13 at 11:53

1 Answers1

0

To expand on @adamkg's comment:

After signing up users via social_auth, you may get the stored data from their social provider's (usually basic things like avatar, id and username) by calling the get_social_auth_for_user method of the UserSocialAuth class.

Some providers stores different extra data, according to this setting, and you may extend this data using a custom pipeline step. For an example of this, have a look at this related question.

Additionally, all providers store tokens and uid, so you can request data as the user's at any time.

So, to get facebook user friends in your view you might do:

social_data = UserSocialAuth.get_social_auth_for_user(request.user)
if social_data.provider == 'facebook':  # get facebook friends
    auth_tokens = social_data.tokens['access_token']
    graph = facebook.GraphAPI(auth_tokens)
    friends = graph.get_connections("me", "friends")
    # now do something with friends ...

In the example above I used facebook which was the first facebook graph client I found on the net: facebook-sdk, which is also available on pypi

Community
  • 1
  • 1
tutuDajuju
  • 10,307
  • 6
  • 65
  • 88