New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AttributeError: 'generator' object has no attribute 'session' #10
Comments
FWIW it seems like when I change:
to
nothing bad seems to happen and I get my token. Does the strategy definitely need to get the original Django request? |
The request is in fact not required but when not used, the strategy used by python social auth looses informations that could be crucial later (in a pipeline for example). |
Ah, sorry, forgot to mention that. Python 2.7.6 |
I couldn't reproduce your bug. |
Sure, it's oauthlib==1.0.1. The bug does seems to be related to what oauthlib is doing in common.py on line 380, but I'm not sure why we'd get different results--looking at the commit history for that project, that line has been there for a long time. |
Well, I still couldn't reproduce but I tried something anyway. |
I reproduced it trying to POST to auth/convert_token as well, using python 3.4 and oauthlib 1.0.1. defusedxml==0.4.1 |
|
Ok, this is a really weird error and it passes through a few modules.
When I try to POST to auth/convert-token, like so:
I get the error:
AttributeError: 'generator' object has no attribute 'session'
I notice that
ConvertTokenView
calls theOAuthLibMixin
forcreate_token_response
:(see rest_framework_social_oauth2/views.py line 34)
This leads down a winding path that eventually gets to oauthlib. In the code below, the header value for
'Django-request-object'
goes from being aWSGIRequest
to agenerator
without any output, the result of theencode
method here:(see oauthlib/common.py line 380)
self.headers = CaseInsensitiveDict(encode(headers or {}))
The problem, then, is that by the time the request gets back to the
SocialTokenGrant
class in your library here:(see rest_framework_social_oauth2/oauth2_grants.py line 80)
It's no longer a real request. And, a few calls down the chain in python-social-auth, it blows up:
(see social/strategies/django_strategy.py line 30
and produces the error:
AttributeError: 'generator' object has no attribute 'session'
Any idea how to work around this? Is there another way to get back to the Django request without having to rely on the headers coming through?
Here are the relevant parts of my requirements.txt:
and settings.py
The text was updated successfully, but these errors were encountered: