n1_*_*n1_ 2 python django facebook python-social-auth
我有一个django应用程序,我为移动应用程序创建API.在用户身份验证方面,我简单地获取登录+传递并执行标准的django登录.当用户登录时,我生成令牌,保存并提供给移动应用程序.
现在谈到Facebook,我想实现python-social-auth库.我知道如何为标准网络实现它,这真的很微不足道.但是我不知道如何将它实现到我的移动API中以及如何将其添加到我的令牌中.
只是想......有没有可能做programatical auth所以我能够创建API方法并从那里调用社交认证的东西?但是如何在Facebook端"允许访问您的个人资料的XY应用程序"页面呢?
任何建议都有帮助 先感谢您.
该文档描述了如何简单地提供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'
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2055 次 |
最近记录: |