title: How can I avoid an authentication dialog in Flex when using HTTPService or URLRequest?
body: <p>This is related to <a href="https://stackoverflow.com/questions/153420/is-it-feasible-to-create-a-rest-client-with-flex">this question</a>. 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.</p>
  
  <p>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.</p>
  
  <p>Here's what my code looks like:</p>
  
  <pre><code>    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);
  </code></pre>
  
  <p>Am I missing something? Is there a better way to approach this?</p>