views:

403

answers:

3

As of a couple of days ago I was able to access my google spreadsheets from an app (in app engine), but today it is broken.

Namely, I could

name= "name of my spreadsheet"
self.client = gdata.spreadsheet.text_db.DatabaseClient()
self.client.GetDatabases(name=name)

and it worked. In fact, that still works when I run with the dev_appserver

But, if crashes when on the app engine. It says it can't parse the XML.

I added some prints to the gdata code and found out that it could not parse it because what it thought was XML was actually just the HTML of the login page.

What is now happening is that the python gdata library does a ('eleanor' is the spreadsheet name)

GET /feeds/documents/private/full?title=eleanor

and gets back

<HTML>
<HEAD>
<TITLE>Moved Temporarily</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Moved Temporarily</H1>
The document has moved <A HREF="https://www.google.com/accounts/
ServiceLogin?
service=writely&amp;passive=true&amp;nui=1&amp;continue=http%3A%2F
%2Fdocs.google.com%2Ffeeds%2Fdocuments%2Fprivate%2Ffull%3Ftitle
%3Deleanor&amp;followup=http%3A%2F%2Fdocs.google.com%2Ffeeds
%2Fdocuments%2Fprivate%2Ffull%3Ftitle%3Deleanor">here</A>.
</BODY>
</HTML>

but, the same GET on the when running locally on the dev_appserver.py returns the proper XML:

<?xml version='1.0' encoding='UTF-8'?><feed xmlns='http://www.w3.org/
2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'
xmlns:docs='http://schemas.google.com/docs/2007' xmlns:batch='http://
schemas.google.com/gdata/batch' xmlns:gd='http://schemas.google.com/g/
2005'><id>http://docs.google.com/feeds/documents/private/full&lt;/
id><updated>2009-10-29T19:14:07.401Z</updated><category scheme=......

I double checked and, yes, my app is authorized to access google docs.

So, what's up with the "Moved Temporarily". Is that a transient problem at the googleplex, or is it some authentication problem?

+3  A: 

Docs is redirecting you to the login page. You need to authenticate before attempting to fetch the spreadsheet. I'm not sure why it's not requiring you to authenticate on the dev server, though.

Nick Johnson
Thanks, but, yes. I did the whole authentication bit: authorize, get tokens, update token. I double-checked my google account and, indeed, my app has "Google Docs" acces (you can check these on your google account). This was all working a couple of days ago and then the google changed something that broke the authentication (if that's the problem). I tried the obvious: revoke access, then re-grant it, but no go.Any Google app engine employees reading this website?
Jose M Vidal
Still, it seems strange that they would return a "moved temporarily" to a request that is not authorized. If I was really not authorized it would make more sense for them to return a 401 "Authorization required" or at least a 404, don't you think?
Jose M Vidal
This is a common approach for user-facing requests: Authentication is handled by another service, so the site has to return a 302 to send the user's browser to the authentication page. I'm not sure why it's doing so on an API URL, though.
Nick Johnson
And I am a Google App Engine employee - but this is a GData or Docs problem. :)
Nick Johnson
+1  A: 

You probably have to unrestricted access to the spreadsheet. You don't have it shared so everyone can view it.
Can read about sharing here.

Ninja Edit:
I didn't realize you could access the spreadsheet directly from app-engine. Google also has some info on how to authenticate with Google Spreadsheets over here. Have you checked the version of your local environment? Maybe this is something new that your dev environment hasn't picked up yet?

Jack M.
Yup, that is the link I used about two months ago to setup my app, which had been working fine until two days ago when google did something (I have not changed anything in my software) that broke it.
Jose M Vidal
I meant, the link to the "Retrieving Authenticated Google Data Feeds with Google App Engine" tutorial. That is the one I used.
Jose M Vidal
A: 

Ok, it now works. The Google has healed itself.

To be clear, I did not change anything in my code and the problem went away. It must have been a transient error at Google.

I'm hoping these type of errors will be really rare, as they bring my whole web app down.

Jose M Vidal