Django invites friends from a social account

I use the social_auth API to login using a social account. Is it possible to invite friends via facebook, twitter, linkedin in social-auth. or in any other way invite friends from your social account. Share your ideas.

+4
source share
1 answer

To expand @adamkg's comment:

After registering users through social_auth, you can get the saved data from your social provider (usually basic things like an avatar, identifier and username) by calling the get_social_auth_for_user method of the get_social_auth_for_user class .

Some providers store different additional data according to this parameter , and you can expand this data using a custom pipeline step . See this question for an example.

In addition, all providers store tokens and uid, so you can request data as a user at any time.

So, to get friends of facebook users, you can 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 above example, I used facebook , which was the first facebook graphic client I found on the net: facebook-sdk , which is also available on pypi

0
source

Source: https://habr.com/ru/post/1495726/


All Articles