1

I have an RSS feed that I need to read, but you need to log in with a valid username and password to get the feed. I was wondering if or how to do this using Actionscript 3.

Right now I have a very simple script that just gets the xml from a provided url and outputs the xml to the console.

I've verified that it works with a feed that doesn't require authentication.

Let me know if code or anything more specific is needed.

Thanks in advance!

Mike
  • 149
  • 2
  • 12
  • 1
    what kind of authentication is this? – Philipp Kyeck Jul 18 '11 at 21:03
  • Its a hudson server that requires the log in info to see the test failures rss feed. I'm not sure on any more specifics than that. I'm trying to get the permissions changed so that to just see those failures a log in isn't needed. – Mike Jul 19 '11 at 14:17

1 Answers1

1

If you're using an http service, you can do basic authorization with by extending the HTTPService :

package{
    import mx.rpc.AsyncToken;
    import mx.rpc.http.mxml.HTTPService;
    import mx.utils.Base64Encoder;

    public class HTTPServiceAuth extends HTTPService
    {
        public var username : String = '';
        public var password : String = '';
        public function HTTPServiceAuth(rootURL:String=null, destination:String=null)
        {
            super(rootURL, destination);
        }

        override public function send(parameters:Object=null ):AsyncToken {
            var enc : Base64Encoder = new Base64Encoder();
            enc.insertNewLines = false;
            enc.encode(username + ':' + password );
            this.headers = {Authorization:"Basic " + enc.toString())};
            super.send(parameters);
        }
    }
}

You use it the same way except you can specify a username and password :

<local:HTTPServiceAuth url="http://www.domain.com/feed/etc" username="myUsername" password="myPassword" ...rest of standard args, etc... />
Nate
  • 2,881
  • 1
  • 14
  • 14
  • I just started flash a few days ago so I'm real new and I haven't tried this. Will look into it and see if this will work. – Mike Jul 19 '11 at 14:17