On upgrading python-social-auth from 0.1.17 to 0.2.4, session attribute is not provided in request, to custom pipeline method?

☆樱花仙子☆ 提交于 2019-12-02 23:35:05

问题


My social-auth pipeline is as follows:

SOCIAL_AUTH_PIPELINE = (
'social.pipeline.social_auth.social_details',
'social.pipeline.social_auth.social_uid',
'social.pipeline.social_auth.auth_allowed',
'social.pipeline.social_auth.social_user',
'social.pipeline.user.get_username',
'social.pipeline.social_auth.associate_by_email',
'social.pipeline.user.create_user',
'social.pipeline.social_auth.associate_user',
'social.pipeline.social_auth.load_extra_data',
'social.pipeline.user.user_details',
'useraccounts.models.create_user_profile'
)

When 'useraccounts.models.create_user_profile' does following:

request = kwargs.get('request')
do_something(session_key=request.session.session_key)

Following error comes:

'QueryDict' object has no attribute 'session'

'Request' dictionary has elements with following keys: state, code, prompt, session_state, authuser

I am using Django version 1.5.5. The problem is coming since I have upgraded python-social-auth from v0.1.17 to v0.2.4


回答1:


https://github.com/omab/python-social-auth/issues/978

Try to use

strategy.request

to access django request.




回答2:


This may be because user_details function doesn't pass anything to next function in pipeline. As per your requirement you might need to change the order of functions in your pipeline:

Check this: https://github.com/omab/python-social-auth/blob/master/social/pipeline/user.py#L75



来源:https://stackoverflow.com/questions/38973264/on-upgrading-python-social-auth-from-0-1-17-to-0-2-4-session-attribute-is-not-p

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!