Python-social-auth如何获得uid fullname等与facebook

时间:2014-01-22 18:22:48

标签: django facebook python-social-auth

social-auth facebook身份验证。

我可以获得用户照片:

 <p>You are logged in as {{ user.username }} !</p>
<img src="http://graph.facebook.com/{{ user.username }}/picture?type=square" > <--working 

代码链接:https://github.com/omgbbqhaxx/python-social-auth/blob/master/examples/django_example/example/templates/done.html

我需要userid,fullname,lastname我该怎么办?你可以给我发拉请求。

1 个答案:

答案 0 :(得分:3)

定义此设置:

SOCIAL_AUTH_FACEBOOK_EXTRA_DATA = ['first_name', 'last_name']

然后您可以使用以下方法访问这些值:

social = user.social_auth.get(provider='facebook')
userid = social.uid
first_name = social.extra_data['first_name']
last_name = social.extra_data['last_name']