jump to navigation

Howto: Add Basic Authentication Header to HTTPService July 4, 2008

Posted by Mayank in actionscript, flex.
Tags: , , , ,

HTTPService in flex supports addition of headers as required. Follow the steps below to add authetication headers to your HTTPService when accessing a service protected by basic authentication.

        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();
            userService.headers["Authorization"] = "Basic " + encoder.toString();




1. Anirudh Sasikumar - July 14, 2008

Hi Mayank,

The following link to an Adobe technote might turn out to be useful since there’s been a lot of questions revolving around the Authorization header getting blacklisted: http://www.adobe.com/go/kb403184


2. Sending Authentication Headers in Flex | Psyked - February 10, 2009

[…] In Flex (with HTTP Service class): https://geekzguru.wordpress.com/2008/07/04/ howto-add-basic-authentication-header-to-httpservice/ […]

3. Abhishek Tiwari - March 7, 2009

@Mayank, @Anirudh

The Auth header doesnt seem to work with Flash 9 and above due to the blacklisting. Is there a way around this?


Mayank - March 8, 2009

What is the complete version of your flash player?

4. Basic HTTP Authorisierung in Actionscript 3 | boxedfolder.com - Flex, Flash & Web - March 29, 2009

[…] Erklärungen gibt es im unten stehenden Artikel. Link zum Artikel. « vorheriger Eintrag 28. März 2009 (19:37 Uhr) – flash & flex, web nach […]

5. anonymous1 - March 3, 2010

How to Add “NTLM Authentication” Header to HTTPService?

6. Ivan Latysh - April 14, 2010

I had the same problem, it is awful that Adobe is not willing to fix such fundamental bugs.

From what I see there are no way around it from the user side, so I solve the issue on the server side.

If you run Tomcat you can try this fix: http://code.google.com/p/web-actions/wiki/FlexBasicAuthenticationValve

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: