0 Replies Latest reply on Aug 27, 2009 6:16 AM by Marc de kwant

    HTTPService basic authorization headers...

    Marc de kwant Level 1



      I am trying to programatically add the Authorization header to a HTTPService call, but apparently the flash player 9 and 10 remove this header. crossdomain.xml with



      <?xml version="1.0"?>

      <!DOCTYPE cross-domain-policy SYSTEM



        <allow-access-from domain="*"/>

        <allow-http-request-headers-from domain="*" headers="Authorization"/>




      Does not work either.


      My code is as follows:



      <?xml version="1.0" encoding="utf-8"?>

      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">




          import mx.controls.Alert;

          import mx.rpc.events.ResultEvent;

          import mx.rpc.events.FaultEvent;

          import mx.utils.Base64Encoder;


             private function addAuthHeader(serv:*, username:String,password:String):void {

                   //add the header to request

                   var encoder : Base64Encoder = new mx.utils.Base64Encoder();

                   encoder.insertNewLines = false;

                   encoder.encode(username + ":" + password);

                   var prop:String = "Basic "+ encoder.toString();

                   serv.headers = {"Authorization":prop};

                   //serv.headers["Authorization"] = "Basic " + encoder.toString();




                 private function getURL():void {

                    addAuthHeader(myService, "admin", "crypticpassw");



                  private function widgetResultHandler(event:ResultEvent):void


                      myText.text = event.result as XML;



                  private function widgetFaultHandler(event:FaultEvent):void


                      Alert.show(event.fault.message, "Oeps..." + event);







      <mx:HTTPService id="myService"







      <mx:Button id="go" label="GO" click="getURL()" x="97" y="145"/>


      <mx:TextArea id="myText" x="97" y="48" width="223" height="89"/>

      <mx:Label x="97" y="22" text="Stop the custom search"/>







      Can anyone tell me how I can get this functionality to work. The numerous examples on the web all look like mine, but none works because the header is removed before sending the request to the server.


      Kind regards,


      Marc de Kwant