Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

gdata spreadsheet examples stop working #25

Open
yuhengh opened this issue Jun 3, 2015 · 3 comments
Open

gdata spreadsheet examples stop working #25

yuhengh opened this issue Jun 3, 2015 · 3 comments

Comments

@yuhengh
Copy link

yuhengh commented Jun 3, 2015

I knew I need to use oauth2 to be able to do that. I tried to modify my script to this post
http://stackoverflow.com/questions/16026286/using-oauth2-with-service-account-on-gdata-in-python

Then I got this error

Traceback (most recent call last):
File "/Applications/PyCharm.app/helpers/pydev/pydevd.py", line 1733, in
debugger.run(setup['file'], None, None)
File "/Applications/PyCharm.app/helpers/pydev/pydevd.py", line 1226, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "/Users/tom/projects/jolu/mobile_framework/tools/config/test.py", line 24, in
feed = gd_client.GetWorksheetsFeed("11HnWT0tHZsRdSd4nY5gktoh0Jg3q_1XEy1Ig-JzfECk")
File "/Library/Python/2.7/site-packages/gdata/spreadsheet/service.py", line 129, in GetWorksheetsFeed
converter=gdata.spreadsheet.SpreadsheetsWorksheetsFeedFromString)
File "/Library/Python/2.7/site-packages/gdata/service.py", line 1069, in Get
headers=extra_headers)
File "/Library/Python/2.7/site-packages/atom/init.py", line 93, in optional_warn_function
return f(_args, *_kwargs)
File "/Library/Python/2.7/site-packages/atom/service.py", line 186, in request
data=data, headers=all_headers)
File "/Library/Python/2.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)

Here's my complete source code

import gdata.spreadsheet.service
import gdata.service
import gdata.spreadsheet
import gdata.gauth
from oauth2client.client import SignedJwtAssertionCredentials
import httplib2

credentials = SignedJwtAssertionCredentials(
"XXXXX@developer.gserviceaccount.com",
open("secret.p12").read(),
scope=(
"https://www.googleapis.com/auth/drive",
"https://spreadsheets.google.com/feeds",
"https://docs.google.com/feeds"
), # For example.
sub="user@gmail.com"
)
http = httplib2.Http()
http = credentials.authorize(http)
auth2token = gdata.gauth.OAuth2TokenFromCredentials(credentials)
gd_client = gdata.spreadsheet.service.SpreadsheetsService() # For example.
gd_client = auth2token.authorize(gd_client)

feed = gd_client.GetWorksheetsFeed("MY_DOC_ID")

Any idea how to fix it? I googled it online and found no working solution so far.
It would be nice to update the examples so it can work again.
Thanks!

@Nixarn
Copy link

Nixarn commented Jun 4, 2015

Yeah, the API seems broken. Some of our script that uses the spreadsheet library fails as well.

@skarra
Copy link

skarra commented Jun 4, 2015

These have not been updated in 4 years in some cases (the Contacts). It's a pity they have not fond time to update it in the 3 years since ClientLogin has been deprecated.

@acornejo
Copy link

acornejo commented Jul 8, 2015

fwiw the problem is the combination of using the "new" oauth2 authentication, together with the "old" service spreadsheet api.

If instead, you use the newer client spreadsheet api, things seem to work. Thus, something along the following lines should work:

credentials = SignedJwt....
token = gdata.gauth.OAuth2TokenFromCredentials(credentials)
client = gdata.spreadsheets.client.SpreadsheetsClient()
client = token.authorize(client)

feed = client.get_spreadsheets()
print feed

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants