Disable AIR's login dialog when using XMLHR with HTTP basic authentication
30 08 2009
While developing an AIR application which uses an online API with HTTP Basic Authentication I experienced issues with AIR's authentication dialog.
For doing the authentication I generated a HTTP authentication header including the login credentials. I appended this header to my XMLHttpRequest. In case the login credentials were correct, everything was fine and the request could be completed successfully. But if the credentials were wrong, AIR showed up with a login window to enter the login data for the given domain. Since most AIR applications will be a fully integrated user experience, I'm sure this would be a drawback for most developers. Another interesting point is, that the login box showed up even before I got notified about an 401-HTTP status response.
For doing the authentication I generated a HTTP authentication header including the login credentials. I appended this header to my XMLHttpRequest. In case the login credentials were correct, everything was fine and the request could be completed successfully. But if the credentials were wrong, AIR showed up with a login window to enter the login data for the given domain. Since most AIR applications will be a fully integrated user experience, I'm sure this would be a drawback for most developers. Another interesting point is, that the login box showed up even before I got notified about an 401-HTTP status response.
So what to do? In the AIR documentation I could find some information about the URLRequestDefaults object which holds some default data for URLRequests. URLRequests own an "authenticate" property which defines if the authentication should be handled by AIR (which causes the dialog, I thought). But when not using URLRequests and using XMLHttpRequests instead, this setting has no effect.
While doing some research I also found an "authenticate" property for the HTMLLoader object. Setting this property to false disables AIR's authentication handling and my application immediately gets informed about an 401.
Disabling AIR's authentication handling can be done in your JS code using:
I suggest to put this in some kind of an "onready" handler:
Written by Sebastian Bauer
Comments : 4 Comments »
Categories : Adobe® AIR™
Trackbacks : No Trackbacks »






Trackbacks
No Trackbacks