8 Replies Latest reply on Jun 6, 2011 6:31 AM by Claudiu Ursica

    Catch HTTP code 401 and prevent standard login dialog




      in my FLEX application I load some data from a Java servlet. I use URLRequest and URLLoader to load the data. The servlet requires basic authentication. I use a custom login dialog to get the users credentials. Everything works fine except when the user provides wrong credentials. Then the servlet returns HTTP code 401 and FLEX automatically shows a standard login dialog. I'd like to show a custom dialog instead. However I have not found a way to catch the 401 code and prevent the standard dialog from showing. Is there a solution for this?


      My code:

      var encoder: Base64Encoder = new Base64Encoder();
      encoder.encode(context.userId + ":" + context.password);
      var credHeader: URLRequestHeader = new URLRequestHeader(
           "Authorization", "Basic " + encoder.toString());
      var loader: URLLoader = new URLLoader();
      var request: URLRequest = new URLRequest("http://.../userinfo");
      request.method = URLRequestMethod.GET;