Howto: Add Basic Authentication Header to HTTPService July 4, 2008
Posted by Mayank in actionscript, flex.Tags: actionscript, as3, authentication, flex, httpservice
trackback
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.
<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>
Enjoyyy!!!

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
Regards,
Anirudh
[...] In Flex (with HTTP Service class): http://geekzguru.wordpress.com/2008/07/04/ howto-add-basic-authentication-header-to-httpservice/ [...]
@Mayank, @Anirudh
The Auth header doesnt seem to work with Flash 9 and above due to the blacklisting. Is there a way around this?
Abhishek
What is the complete version of your flash player?
[...] Erklärungen gibt es im unten stehenden Artikel. Link zum Artikel. « vorheriger Eintrag 28. März 2009 (19:37 Uhr) – flash & flex, web nach [...]