Closed rigaspapas closed 7 years ago
"request" at pipeline kwargs is not django request. It is QueryDict , that using by PSA with tokens and etc. If you want access django wsgi request, you must use "strategy.request" value.
Thanks! I was expecting to find that information at the Pipeline page of the documentation. Another problem worth mentioning when having a custom user system in Django, is that when you disable the AuthenticationMiddleware
, request.user
is not defined, leading to an error. Is there a workarround with that?
I have recently upgraded from v0.1.17 to v0.2.4, and my code is breaking when it tried to access session as follows:
request = kwargs.get('request')
do_something(session_key=request.session.session_key)
Error: 'QueryDict' object has no attribute 'session'
As per your conversation, since this request
is not django request, hence I am getting above error, but this code was working fine before upgrade. Any idea, why is this so?
The Django request
can be accessed at strategy.request
.
When you add a function to the pipeline you have access to a
request
keyword argument. Thisrequest
object contains only the GET (or POST) data we received when user got redirected to our callback URL. The only information we have about the authenticity of the user's request is theuser
parameter which is in fact therequest.user
value. Having a custom user system in Django won't work with that. We need to have access to the whole request object to decide whether it was authenticated. My workarround to achieve this was to override thecomplete
view function in order to add the whole request object to the keyword arguments. Is there a better way to achieve this or any chance of making such changes in the future?