I’ve done a lot of work on my aforementioned foursquare / last.fm mashup project, which I’m still not exactly ready to start crowing about, but whose source is, as ever, available.
I’m currently hitting a bunch of problems in getting my Python code to work while it’s deployed out to Google’s appspot.com production environments. I’ve been able to authenticate successfully against foursquare from my local environment, following their straightforward instructions, but every time I try to run the same code out in Google’s cloud, once I hit the point where I retrieve an access code from foursquare and make a request for a legit session token, this is what I wind up with:
HTTP blarg, feh
Traceback (most recent call last):
File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 545, in dispatch
return method(*args, **kwargs)
File "/base/data/home/apps/s~how-you-been/0-2-4.357616581640073459/whence.py", line 97, in get
accessCode = self.getFoursquareAccessToken(code)
File "/base/data/home/apps/s~how-you-been/0-2-4.357616581640073459/howyoubeen/Foursquare.py", line 49, in getFoursquareAccessToken
httpResponse = urllib2.urlopen(url)
File "/base/python27_runtime/python27_dist/lib/python2.7/urllib2.py", line 126, in urlopen
return _opener.open(url, data, timeout)
File "/base/python27_runtime/python27_dist/lib/python2.7/urllib2.py", line 400, in open
response = meth(req, response)
File "/base/python27_runtime/python27_dist/lib/python2.7/urllib2.py", line 513, in http_response
'http', request, response, code, msg, hdrs)
File "/base/python27_runtime/python27_dist/lib/python2.7/urllib2.py", line 438, in error
return self._call_chain(*args)
File "/base/python27_runtime/python27_dist/lib/python2.7/urllib2.py", line 372, in _call_chain
result = func(*args)
File "/base/python27_runtime/python27_dist/lib/python2.7/urllib2.py", line 521, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
Dang it! My initial instinct is that I’m hitting a timeout in Google’s cloud environment, but are they honestly passing a 404 back to my stack at that point? (I suspect, as an alternate explanation, something about my error-handling handlers are deficient.)
While looking into this I’ve stumbled upon a few Python OAuth2 libraries, about which OAuth2 isn’t exactly rocket science, but if the libraries have a decent interface and can overcome this issue, maybe I’ll give them a shake. (On the js side of the world I’ve been having a few similar issues, where I’d like to move to an open-source library but the ones I’ve seen make odd assumptions about the execution environment.)
Another possibility I’ve considered is that there’s some sort of SSL wildcard issue at play, as suggested by this stack overflow answer which foursquare has bravely elected as their replacement for tech support. But for now,
.
vfaronov
/ March 20, 2012What in the traceback you posted makes you believe it is a 404 error?
Do you actually get “blarg, feh”?
timgilbert
/ March 20, 2012“Blarg, feh” would be an unusually terse error message from Google, but in fact it’s the message that I’m using when I catch and re-throw the exception. I should have posted the code in question, it’s as follows:
try: httpResponse = urllib2.urlopen(url) except urllib2.HTTPError as err: logging.error(err) trace = sys.exc_info()[2] raise Exception('HTTP blarg, feh'), None, traceI may try changing this to use GAE’s urlfetch services instead and see if I can get a more detailed error. The frustrating thing is that requesting the same URL from my browser works fine.
timgilbert
/ March 28, 2012In the interest of posterity, I’ve been able to replicate this error locally and it seems to be a bug in my own code, not something related to GAE deployment.