我正在使用python构建适用于bigcommerce的应用,
使用bigcommerce SDK(https://github.com/bigcommerce/bigcommerce-api-python)
在Google App Engine上运行
在尝试从bigcommerce提取令牌时遇到以下错误:
File "/base/data/home/apps/s~acp-bigcommerce/20161220t174745.397888154524804049/lib/bigcommerce/api.py", line 22, in oauth_fetch_token
return self.connection.fetch_token(client_secret, code, context, scope, redirect_uri, token_url)
File "/base/data/home/apps/s~acp-bigcommerce/20161220t174745.397888154524804049/lib/bigcommerce/connection.py", line 250, in fetch_token
headers={'Content-Type': 'application/x-www-form-urlencoded'})
File "/base/data/home/apps/s~acp-bigcommerce/20161220t174745.397888154524804049/lib/bigcommerce/connection.py", line 140, in post
response = self._run_method('POST', url, data=data, headers=headers)
File "/base/data/home/apps/s~acp-bigcommerce/20161220t174745.397888154524804049/lib/bigcommerce/connection.py", line 72, in _run_method
return self._session.request(method, url, data=data, timeout=self.timeout, headers=headers)
File "/base/data/home/apps/s~acp-bigcommerce/20161220t174745.397888154524804049/lib/requests/sessions.py", line 488, in request
resp = self.send(prep, **send_kwargs)
File "/base/data/home/apps/s~acp-bigcommerce/20161220t174745.397888154524804049/lib/requests/sessions.py", line 641, in send
r.content
File "/base/data/home/apps/s~acp-bigcommerce/20161220t174745.397888154524804049/lib/requests/models.py", line 781, in content
self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()
File "/base/data/home/apps/s~acp-bigcommerce/20161220t174745.397888154524804049/lib/requests/models.py", line 706, in generate
raise ChunkedEncodingError(e)
ChunkedEncodingError: ('Connection broken: IncompleteRead(108 bytes read)', IncompleteRead(108 bytes read))
最佳答案
如果您在Google App Engine中使用requests
,建议您也使用requests_toolbelt
。
您可以here了解更多信息。
在您的代码中,只需使用
from requests_toolbelt.adapters import appengine
appengine.monkeypatch()