Python AppEngine下载错误上的Dropbox明文REST API

Python AppEngine下载错误上的Dropbox明文REST API,python,google-app-engine,oauth,dropbox-api,Python,Google App Engine,Oauth,Dropbox Api,我觉得我在吃疯狂的药片。我制作了一个dropbox API小应用程序,它: 使用/diff API获取/照片的列表 获取每张照片 解析EXIF数据 将EXIF数据存储回appengine 我编写了它,它在dev_appserver上运行得很好,但部署到appengine时失败了 对/delta的调用正常工作,但对/files的调用失败,出现不透明的“DownloadError”。 无论如何,下面是相关的代码块: def fetch_image(self, path): url = 'http

我觉得我在吃疯狂的药片。我制作了一个dropbox API小应用程序,它:

  • 使用/diff API获取/照片的列表
  • 获取每张照片
  • 解析EXIF数据
  • 将EXIF数据存储回appengine
  • 我编写了它,它在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_头生成如下输出:

    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>"
    

    OAuth-OAuth-version=“1.0”,OAuth-OAuth-signature\u-method=“明文”,OAuth-OAuth-consumer\u密钥=“因为它是在api上工作的,而不是在api内容上,但我还不能为此设置测试。即使是这样,我也无能为力。

    所以我已经弄明白了。基本上,我没有正确编码请求url。我得到的是:

    Event/Some File Name.jpg

    失败了,但是:

    工作

    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**