flask-oauth
flask-oauth copied to clipboard
TypeError: must be string or buffer, not None
Traceback (most recent call last): File "~/env/lib/python2.7/site-packages/flask/app.py", line 889, in call return self.wsgi_app(environ, start_response) File "~/env/lib/python2.7/site-packages/flask/app.py", line 879, in wsgi_app response = self.make_response(self.handle_exception(e)) File "~/env/lib/python2.7/site-packages/flask/app.py", line 876, in wsgi_app rv = self.dispatch_request() File "~/env/lib/python2.7/site-packages/flask/app.py", line 695, in dispatch_request return self.view_functionsrule.endpoint File "~/blog/views.py", line 94, in index resp = twitter.get('statuses/home_timeline.json') File "~/env/lib/python2.7/site-packages/flaskext/oauth.py", line 173, in get return self.request(_args, *_kwargs) File "~/env/lib/python2.7/site-packages/flaskext/oauth.py", line 239, in request body=data, headers=headers)) File "~/env/lib/python2.7/site-packages/oauth2/init.py", line 662, in request req.sign_request(self.method, self.consumer, self.token) File "~/env/lib/python2.7/site-packages/oauth2/init.py", line 493, in sign_request self['oauth_body_hash'] = base64.b64encode(sha(self.body).digest()) TypeError: must be string or buffer, not None
Evidently, self.body can't be None but is always being set to None for GET requests.
Here is the problem line in oauth2/init.py...
if not self.is_form_encoded: 488 # according to 489 # http://oauth.googlecode.com/svn/spec/ext/body_hash/1.0/oauth-bodyhash.html 490 # section 4.1.1 "OAuth Consumers MUST NOT include an 491 # oauth_body_hash parameter on requests with form-encoded 492 # request bodies." 493 self['oauth_body_hash'] = base64.b64encode(sha(self.body).digest())
Here's a patch: https://gist.github.com/1020196
I also had this issue this patch fix it, thanks a lot