flask-social-blueprint
flask-social-blueprint copied to clipboard
GAE: ChunkedEncodingError: ('Connection broken: IncompleteRead(207 bytes read)', IncompleteRead(207 bytes read))
There seem to be a problem with updated requests library on Google App Engine.
Exception on /_social/callback/Github [GET]
Traceback (most recent call last):
File "/base/data/home/apps/s~flask-social-blueprint/3.389521229691342073/lib/flask/app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "/base/data/home/apps/s~flask-social-blueprint/3.389521229691342073/lib/flask/app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/base/data/home/apps/s~flask-social-blueprint/3.389521229691342073/lib/flask/app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/base/data/home/apps/s~flask-social-blueprint/3.389521229691342073/lib/flask/app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "/base/data/home/apps/s~flask-social-blueprint/3.389521229691342073/lib/flask/app.py", line 1461, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/base/data/home/apps/s~flask-social-blueprint/3.389521229691342073/lib/flask_social_blueprint/core.py", line 44, in callback
return provider.authorized_handler(self.login)(provider=provider)
File "/base/data/home/apps/s~flask-social-blueprint/3.389521229691342073/lib/flask_oauth.py", line 433, in decorated
return f(*((data,) + args), **kwargs)
File "/base/data/home/apps/s~flask-social-blueprint/3.389521229691342073/lib/flask_social_blueprint/core.py", line 54, in login
profile = provider.get_profile(raw_data)
File "/base/data/home/apps/s~flask-social-blueprint/3.389521229691342073/lib/flask_social_blueprint/providers.py", line 179, in get_profile
r = requests.get('https://api.github.com/user?access_token={}'.format(access_token))
File "/base/data/home/apps/s~flask-social-blueprint/3.389521229691342073/lib/requests/api.py", line 67, in get
return request('get', url, params=params, **kwargs)
File "/base/data/home/apps/s~flask-social-blueprint/3.389521229691342073/lib/requests/api.py", line 53, in request
return session.request(method=method, url=url, **kwargs)
File "/base/data/home/apps/s~flask-social-blueprint/3.389521229691342073/lib/requests/sessions.py", line 468, in request
resp = self.send(prep, **send_kwargs)
File "/base/data/home/apps/s~flask-social-blueprint/3.389521229691342073/lib/requests/sessions.py", line 608, in send
r.content
File "/base/data/home/apps/s~flask-social-blueprint/3.389521229691342073/lib/requests/models.py", line 737, in content
self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()
File "/base/data/home/apps/s~flask-social-blueprint/3.389521229691342073/lib/requests/models.py", line 663, in generate
raise ChunkedEncodingError(e)
ChunkedEncodingError: ('Connection broken: IncompleteRead(207 bytes read)', IncompleteRead(207 bytes read))
I may or may not be connected to a InsecurePlatformWarning:
/base/data/home/apps/s~flask-social-blueprint/3.389521229691342073/lib/requests/packages/urllib3/util/ssl_.py:120: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
Solution:
https://urllib3.readthedocs.org/en/latest/security.html#pyopenssl
results:
Traceback (most recent call last):
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
File "/base/data/home/apps/s~flask-social-blueprint/3.389521383891920475/main.py", line 74, in <module>
import urllib3.contrib.pyopenssl
File "/base/data/home/apps/s~flask-social-blueprint/3.389521383891920475/lib/urllib3/contrib/pyopenssl.py", line 49, in <module>
from ndg.httpsclient.ssl_peer_verification import SUBJ_ALT_NAME_SUPPORT
ImportError: No module named ndg.httpsclient.ssl_peer_verification
Solution http://stackoverflow.com/a/29507367/260480
e33d26a3dafc635a46930358132f3a5f8b71356f
Have no effect.
I'm having the same problem: ChunkedEncodingError on GAE. No InsecurePlatformWarning though. I'm only trying to access the web service with http, not https
I'm having the same issue on GAE, try this solution : https://github.com/kennethreitz/requests/compare/master...agfor:master
From : https://github.com/shazow/urllib3/issues/618
@cnicodeme You sir are a legend! Solved this issue for me - thank you!
In situations where "requests" is a dependency by other packages , you may not be easily able to provide your own library This code patches the existing classes, and you can call it from your init.py
gae_request_incompleteReadFix.txt
Tested with GAE Works!