This is related to this question. I'm writing a Flex app (a WindowedApplication) that uses REST. Everything's fine when I post with valid authentication, but if I happen to pass an invalid username or password to the REST API (a Twitter REST API, to be specific), an authentication dialog pops up.
That's not a desirable user experience, and it happens both when I use HTTPService and URLRequest. There doesn't seem to be an event I can catch to cancel the dialog.
Here's what my code looks like:
var request:URLRequest = new URLRequest('http://twitter.com/statuses/update.json');
request.method = URLRequestMethod.POST;
var encoder : Base64Encoder = new Base64Encoder();
encoder.encode(this.user + ':' + this.password);
request.requestHeaders.push(new URLRequestHeader("Authorization", "Basic " + encoder.toString()));
var params:Object = new Object();
params.status = msg;
request.data = params;
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, HandleRequestComplete);
loader.load(request);
Am I missing something? Is there a better way to approach this?