低级atom TypeError:new\u request()在调用gdata的电子表格服务.GetSpreadsheetsFeed()

2024-09-30 08:37:51 发布

您现在位置:Python中文网/ 问答频道 /正文

我一直在通过曲折的通道,这是谷歌应用程序API文档迷宫追逐。我想知道如何使用pythonapi来更新googlesheets文档。你知道吗

我能够成功地运行OAuth2流,并且如果我正确地遵循了这些操作,我已经生成了一个有效的OAuth2令牌并授权了SpreadsheetsService客户机。你知道吗

这是我正在执行的代码块。你知道吗

storage = Storage(CREDENTIALS_PATH)

flow = flow_from_clientsecrets(CLIENT_SECRETS_PATH, scope=SCOPE)
credentials = oauth2client.tools.run_flow(flow, storage, args)

print credentials.token_expiry
print credentials.scopes

gdss_client = gdata.spreadsheet.service.SpreadsheetsService()
oauth2_token = gdata.gauth.OAuth2TokenFromCredentials(credentials)

gdss_client = oauth2_token.authorize(gdss_client)
gdss_client.GetSpreadsheetsFeed()

结果如下:

2016-04-22 18:58:56
set([u'https://spreadsheets.google.com/feeds'])

Traceback (most recent call last):
  File "./sheets.py", line 159, in <module>
    main()
  File "./sheets.py", line 154, in main
    gdss_client.GetSpreadsheetsFeed()
  File "/Users/browsc3/.virtualenvs/boogio/lib/python2.7/site-packages/gdata/spreadsheet/service.py", line 98, in GetSpreadsheetsFeed
    converter=gdata.spreadsheet.SpreadsheetsSpreadsheetsFeedFromString)
  File "/Users/browsc3/.virtualenvs/boogio/lib/python2.7/site-packages/gdata/service.py", line 1068, in Get
    headers=extra_headers)
  File "/Users/browsc3/.virtualenvs/boogio/lib/python2.7/site-packages/atom/__init__.py", line 92, in optional_warn_function
    return f(*args, **kwargs)
  File "/Users/browsc3/.virtualenvs/boogio/lib/python2.7/site-packages/atom/service.py", line 185, in request
    data=data, headers=all_headers)
  File "/Users/browsc3/.virtualenvs/boogio/lib/python2.7/site-packages/atom/http_interface.py", line 148, in perform_request
    return http_client.request(operation, url, data=data, headers=headers)
TypeError: new_request() takes exactly 1 argument (4 given)

由于所有这些的文档似乎都包含了个别类在某个时间点存在的零星的不连贯的描述,以及对外部类的松散引用,这些外部类可能有或可能没有特定的相关文档,所以我这样做可能是完全错误的。如果有人能对我的方法有所了解,我将不胜感激。你知道吗


Tags: inpyclientlibpackageslinesitevirtualenvs
2条回答

Oauth和gdataapi不同步。你知道吗

不要创建oauth2token对象,只需执行以下操作:

gd_client = gdata.photos.service.PhotosService(
  additional_headers={'Authorization' : 'Bearer ' + credentials.access_token})

这似乎对我很有帮助。你知道吗

这个链接提供了答案:

https://github.com/google/gdata-python-client/issues/25

替换

gdss_client = gdata.spreadsheet.service.SpreadsheetsService()
oauth2_token = gdata.gauth.OAuth2TokenFromCredentials(credentials)

gdss_client = oauth2_token.authorize(gdss_client)
gdss_client.GetSpreadsheetsFeed()

gdss_client = gdata.spreadsheets.client.SpreadsheetsClient()
oauth2_token = gdata.gauth.OAuth2TokenFromCredentials(credentials)

gdss_client = oauth2_token.authorize(gdss_client)
gdss_client.gdss_client.get_spreadsheets()

相关问题 更多 >

    热门问题