views:

91

answers:

1

I'm having a heck of a time trying to figure this one out.

I've got a simple YouTube API client put together, written in Flex, that uses a plain ol' URLRequest object to handle Google's "ClientLogin" authentication scheme. Everything works perfectly, except for one case: when Google responds with a 403 and a response body indicating that I should prompt the user for additional information (specifically, a CAPTCHA request).

The problem I'm having is that in this case, I need to be able to retrieve the body of the 403 response, as the body contains information Google expects me to use to assemble the CAPTCHA (e.g., an image URL, etc.). It looks like Flash fails to populate the URLLoader's data property when it encounters a 403 (which is where the response body would normally show up), so I can't tell the difference between a "403: Login Failed" and a "403: Login Succeeded, but We Want a CAPTCHA".

As a backup, I figured I'd have a look at as3crypto's TLSSocket code, but I haven't been able to make any of that stuff work with Google (or even one of my own SSL certs, for that matter).

So my question is twofold:

  1. Is it possible to access the body of a 403 response with Flash (and if so, how)? And if not,
  2. Does anyone have personal experience with a suitable workaround?

Many thanks in advance -- I'm pretty much stuck on this one.

A: 

You can get the response by using HTTPService instead of URLLoader. HTTPService loads the response even in cases of any status code (200, 404, 403 etc.). I've been using it for quite some time.

PS: I use this in Picasa Web APIs for user-authentication.

Sai Prasad
One thing I'm not seeing, though, is where to retrieve the body of the result. I don't seem to see anything on the HTTPOperation object. Any clues you could provide?
Christian Nunciato
It is HTTPService Object. You need to listen to ResultEvent.RESULT event. In the event handler, event.data would contain the the response. In case of clientLogin, event.data should be XML. So, you can get the response as var response:XML = new XML(event.data)
Sai Prasad
Hm, I don't seem to be getting a RESULT event with HTTP status 400 (from the GData YouTube API, in this case). Haven't tried yet with 403, but 400 is definitely not returning any body that I can discern. With 400, all I get is a FAULT.
Christian Nunciato