Closed rwilcox closed 14 years ago
Doesn't it return non-200 response code? Is the response structured XML or just plain HTML? It would be nice to use some way better than using regexp of error message if it's possible. I haven't set up environment to test OAuth authentication, so it's a bit hard to test it for me...
That's a good idea about checking the response code.
I did the regex on the assumption that there might be other errors reported back from Google and that we'd interrogate the title to figure out what kind of (semantic) error to throw. Today, AuthSubToken, tomorrow Google throws back a "AuthSubToken - Invalid" error (via the title) and we have throw something semantic back to the users of the library.
On that front, actually, I ran across that problem today in using the module. My head now will throw Net::HTTPBadResponse exceptions if we get something that is not success.
The "checking for AuthSubToken" code takes precedence over this generic error handling
Do you know if it returns 200 response code for AuthToken error? If not, it would be nice to throw the exception only if the code is non-200 and it matches the regex, because it's theoretically possible that the spreadsheet cell contains the "Token invalid" message. Also it would be nice if you send me full XML or HTML of the response when the error happens.
It looks it returns 401 for invalid token error, by gooling a bit. So I applied same error handling as non-OAuth case in: http://github.com/gimite/google-spreadsheet-ruby/commit/83d4044e3b187f5dd8f2adfd6b77db076eaddc89 Now it should raise GoogleSpreadsheet::AuthenticationError for invalid token error.
Awesome! Might want to check out some of my further commits on my repo, because I also have a generic error fallback: if it's not HTTP Success (based) error code, I throw an exception.
Yeah it's also implemented. Actually it was already implemented for non-OAuth case.
Hi!
I'm using OAuth with this gem and I ran into an odd error. In debugging this, I found I was getting '\n
\nThe gem wasn't recognizing this error, so I added code to do this. My commits could be cleaner, and I'm sorry about that, but the idea is there - feel free to pull or make changes to my commits as you see fit.
Let me know if I can help, and thank you very much for the gem! _Ryan Wilcox