简体   繁体   中英

Using get_user_details in django-social-auth

I am trying to use django-social-auth to allow my users to log into the website using Facebook. I want to save the first and last name, and email of the user. However, using the setup in the documentation, it saves the username, email and auth token, but for some reason it does not save the first and last names. Looking at the code, the FacebookBackend class provides the function get_user_details but I am not sure how it can be used. It would seem that there should be a simple way to obtain this information. If not, there is always the option to add an additional pipeline .

First and lastname are already retrieved by the default pipeline. The facebook backend calls get_user_details (line 47) which sets first and last name.

The default pipeline even updates these details by calling the method again on each succesful login. This behaviour can be turned off by composing your own pipeline excluding:

'social_auth.backends.pipeline.user.update_user_details'

So either your facebook user doesn't have a first and last name set, or your settings might be wrong, which version are you running?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM