我觉得我正在服用疯狂的药片。我制作了一个小型Dropbox API应用程序:
我写了它并且它在dev_appserver上工作得很好,但在部署到appengine时失败了。
对/ delta的调用正常工作,但对/ files的调用失败并出现不透明" DownloadError"。
无论如何,这是相关的代码块:
def fetch_image(self, path):
url = 'https://api-content.dropbox.com/1/files/dropbox' + path
try:
result = urlfetch.fetch(
url=url,
method=urlfetch.GET,
allow_truncated=True,
headers={ 'Authorization': get_authorization_header(self.authorization) })
except DownloadError, exception:
logging.exception(exception)
logging.debug(get_authorization_header(self.authorization))
def get_delta(self, cursor=None):
url = 'https://api.dropbox.com/1/delta'
params = {
'path_prefix': '/Photos',
}
if cursor is not None:
params['cursor'] = cursor
result = urlfetch.fetch(
url=url,
method=urlfetch.POST,
payload=urllib.urlencode(params),
headers={ 'Authorization': get_authorization_header(self.authorization) })
return json.loads(result.content)
get_authorization_header产生如下输出:
OAuth oauth_version="1.0", oauth_signature_method="PLAINTEXT", oauth_consumer_key="<app-key>", oauth_token="<access-token>", oauth_signature="<app-secret>&<access-token-secret>"
示例堆栈跟踪显示似乎没有任何error_detail。
Unable to fetch URL: https://api-content.dropbox.com/1/files/dropbox/Photos/**redacted** Traceback (most recent call last): File "/base/data/home/apps/**redacted**", line 295, in update_image headers={ 'Authorization': getAuthorizationHeader(self.authorization) }) File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/urlfetch.py", line 270, in fetch return rpc.get_result() File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/apiproxy_stub_map.py", line 612, in get_result return self.__get_result_hook(self) File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/urlfetch.py", line 416, in _get_fetch_result raise DownloadError("Unable to fetch URL: " + url + error_detail) DownloadError: Unable to fetch URL: https://api-content.dropbox.com/1/files/dropbox/Photos/**redacted**
我模糊地怀疑这可能与appengine将授权标题变成question 14716545中发生的事情有关,因为它适用于api而不是api-content,但我还没有能够设置对此进行了测试。即使是这种情况,我也无能为力。
答案 0 :(得分:0)
所以我想通了。基本上我没有正确编码请求网址。我得到了类似的东西:
https://api-content.dropbox.com/1/files/dropbox/Photos/Some活动/一些文件Name.jpg
失败了,但是:
https://api-content.dropbox.com/1/files/dropbox/Photos/Some%20Event/Some%20File%20Name.jpg
作品!