我有一个django应用程序,我为移动应用程序创建API。当涉及到用户身份验证时,我简单地使用login + pass,然后执行标准的django登录操作。当用户登录时,我生成一个令牌,保存它并提供给移动应用程序。
现在谈到Facebook,我想实现python-social-auth库。我确实知道如何在标准web上实现它,它真的很简单。但我不知道,如何将其实现到我的移动API中,以及如何在那里合并我的令牌内容。
只是在想。有没有可能进行编程身份验证,这样我就可以创建API方法,并从那里调用社交身份验证的东西?但是在facebook端的“允许访问XY应用程序到你的个人资料”页面呢?
任何建议都是有帮助的。提前谢谢你。
发布于 2015-03-10 00:15:42
documentation描述了如何简单地提供access_token来验证/创建用户。
from django.contrib.auth import login
from social.apps.django_app.utils import psa
# Define an URL entry to point to this view, call it passing the
# access_token parameter like ?access_token=<token>. The URL entry must
# contain the backend, like this:
#
# url(r'^register-by-token/(?P<backend>[^/]+)/$',
# 'register_by_access_token')
@psa('social:complete')
def register_by_access_token(request, backend):
# This view expects an access_token GET parameter, if it's needed,
# request.backend and request.strategy will be loaded with the current
# backend and strategy.
token = request.GET.get('access_token')
user = request.backend.do_auth(request.GET.get('access_token'))
if user:
login(request, user)
return 'OK'
else:
return 'ERROR'https://stackoverflow.com/questions/24434697
复制相似问题