Add the request headers (as in the code), where userService is an 
HTTPService, baseUrl is the page you need to be authorized to use, 
and auth is the username:password (I'm assuming - I got this example 
from here:
http://geekzguru.wordpress.com/2008/07/04/howto-add-basic-
authentication-header-to-httpservice/

Also check the Adobe TechNote here:
http://kb.adobe.com/selfservice/viewContent.do?
externalId=kb403184&sliceId=2


<mx:Script>
    <![CDATA[
        import mx.utils.Base64Encoder;
        import mx.controls.Alert;

        private var baseUrl:String 
= "http://phprestsql.sourceforge.net/tutorial/user";;
        private var auth:String = "p126371rw:demo";

        private function init():void{
            var encoder : Base64Encoder = new Base64Encoder();
            encoder.encode(auth);
            userService.headers["Authorization"] = "Basic " + 
encoder.toString();
            deleteUser();
        }
    ]]>
</mx:Script>


Please not - I googled for this and found everything above - I've 
never tried it - so I have no clue if it actually works... :D



--- In flexcoders@yahoogroups.com, "wdsnapper" <[EMAIL PROTECTED]> wrote:
>
> Anyone out there understand how to get Flex working with a simple 
Basic Auth protected 
> REST API?  If not is there a fundamental reason why this does not 
work in Flex?  It seems 
> like such a core basic (no pun intended) piece of functionality for 
a Flex app to hook up to 
> an existing XML based service to provide a new view.
> 
> 
> --- In flexcoders@yahoogroups.com, "wdsnapper" <wdsnapper@> wrote:
> >
> > I'm trying to access a basic auth protected site from Flex and 
not having any success.  I 
> see 
> > that you can no longer add the "Authorization" header as you 
could over a year ago.
> > 
> > The setCredentials and setRemoteCredentials methods in the 
HTTPService class seem 
> like 
> > they should do the trick but I've had no luck with them.
> > 
> > Does someone out there have a pointer to a functional example 
showing how to use 
> Basic 
> > Auth from Flex?  I've seen a lot of posts in this forum but have 
been unable to find a 
> solution.
> > 
> > Thanks in advance.
> >
>


Reply via email to