2

我有以下代码,读取 oauth2 令牌表单文件,然后尝试执行文档的列表查询以查找我要复制的特定电子表格,但是无论我尝试什么代码,要么出错,要么返回不包含文档的对象数据。

我正在使用 gdata.docs.client.DocsClient,据我所知,这是 API 的第 3 版

def CreateClient():
"""Create a Documents List Client."""
client = gdata.docs.client.DocsClient(source=config.APP_NAME)
client.http_client.debug = config.DEBUG
# Authenticate the user with CLientLogin, OAuth, or AuthSub.

if os.path.exists(config.CONFIG_FILE):
    f = open(config.CONFIG_FILE)
    tok = pickle.load(f)
    f.close()
    client.auth_token = tok.auth_token

return client

第一次查询尝试

def get_doc():


new_api_query = gdata.docs.client.DocsQuery(title='RichSheet', title_exact=True, show_collections=True)

d = client.GetResources(q = new_api_query)

这失败并出现以下堆栈跟踪

    Traceback (most recent call last):
  File "/Users/richard/PycharmProjects/reportone/make_my_report.py", line 83, in <module>
    get_doc()
  File "/Users/richard/PycharmProjects/reportone/make_my_report.py", line 57, in get_doc
    d = client.GetResources(q = new_api_query)
  File "/Users/richard/PycharmProjects/reportone/gdata/docs/client.py", line 151, in get_resources
    **kwargs)
  File "/Users/richard/PycharmProjects/reportone/gdata/client.py", line 640, in get_feed
    **kwargs)
  File "/Users/richard/PycharmProjects/reportone/gdata/docs/client.py", line 66, in request
    return super(DocsClient, self).request(method=method, uri=uri, **kwargs)
  File "/Users/richard/PycharmProjects/reportone/gdata/client.py", line 267, in request
    uri=uri, auth_token=auth_token, http_request=http_request, **kwargs)
  File "/Users/richard/PycharmProjects/reportone/atom/client.py", line 115, in request
    self.auth_token.modify_request(http_request)
  File "/Users/richard/PycharmProjects/reportone/gdata/gauth.py", line 1047, in modify_request
    token_secret=self.token_secret, verifier=self.verifier)
  File "/Users/richard/PycharmProjects/reportone/gdata/gauth.py", line 668, in generate_hmac_signature
    next, token, verifier=verifier)
  File "/Users/richard/PycharmProjects/reportone/gdata/gauth.py", line 629, in build_oauth_base_string
    urllib.quote(params[key], safe='~')))
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib.py", line 1266, in quote
    if not s.rstrip(safe):
AttributeError: 'bool' object has no attribute 'rstrip'

Process finished with exit code 1

然后我的第二次尝试

def get_doc():

    other = gdata.docs.service.DocumentQuery(text_query='RichSheet')

    d = client.GetResources(q = other)

这返回一个 ResourceFeed 对象,但没有内容。我已经浏览了这些功能的源代码,但事情并不明显。

我错过了什么吗?还是我应该回到 api 的第 2 版?

4

0 回答 0