Getting User Information from Django Python Social Auth in the view

1.4k Views Asked by At

First time working with python-social-auth and Django but having trouble figuring out exactly how much information about the user's social account is available to me.


When I access the extra_data of the UserSocialAuth object I can get the uid, and the access_token. To get additional details am I to feed those through the social company's (ex facebook) API?


I can see that for some social auths like facebook Django's user object is magically populated with the first and last names from the social profile, but for others like LinkedIn that doesn't work. How do i find out which information is available for each social auth without manually probing each one?


I'm just trying to get as much "Profile" data from the user and am worried going through the API is the "long way" of achieving this. I have actually read through the documentation but it may be too advanced for me; im not sure how to use the data that is acquired by the pipeline from the view. I'm not even sure if that sentence makes sense!

1

There are 1 best solutions below

0
On BEST ANSWER

python-social-auth will just fetch the necessarily bits to fill:

  • email
  • username
  • first name
  • last name

Some APIs will provide more details during the authentication flow, those can be saved in extra_data based on the SOCIAL_AUTH_EXTRA_DATA setting.

Some backends will issue a call to an API in the provider to fetch the extra data. An easy way to debug the data available, is to add a custom pipeline in between the default steps and print everything in the args.

As per the uid and access_token, yes, you are right, when calling any API served by the provider will require these values, sometimes both, sometimes access_token is enough.