Omr*_*tix 5 python-social-auth
我在过去的两个月里使用python social auth进行社交认证,这很棒.我需要QQ支持,因此安装了最新的git commit(23e4e289ec426732324af106c7c2e24efea34aeb - 不是发布的一部分).到目前为止,我曾使用以下代码对用户进行身份验证:
# setup redirect uri in order to load strategy
uri = redirect_uri = "social:complete"
if uri and not uri.startswith('/'):
uri = reverse(redirect_uri, args=(backend,))
# load the strategy
try:
strategy = load_strategy(
request=request, backend=backend,
redirect_uri=uri, **kwargs
)
strategy = load_strategy(request=bundle.request)
except MissingBackend:
raise ImmediateHttpResponse(HttpNotFound('Backend not found'))
# get the backend for the strategy
backend = strategy.backend
# check backend type and set token accordingly
if isinstance(backend, BaseOAuth1):
token = {
'oauth_token': bundle.data.get('access_token'),
'oauth_token_secret': bundle.data.get('access_token_secret'),
}
elif isinstance(backend, BaseOAuth2):
token = bundle.data.get('access_token')
else:
raise ImmediateHttpResponse(HttpBadRequest('Wrong backend type'))
# authenticate the user
user = strategy.backend.do_auth(token)
Run Code Online (Sandbox Code Playgroud)
工作得很好.
在最新版本中,此行为已更改,并且由于"load_strategy"方法已更改,因此引发了异常.
我似乎无法找到有关如何使用新版本执行此操作的任何文档.
任何帮助,将不胜感激!
暗利.
| 归档时间: |
|
| 查看次数: |
1252 次 |
| 最近记录: |