Search code examples
djangopython-social-auth

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


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


Solution

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

    Try to use

    strategy.request
    

    to access django request.