Facebook Server AIR vs Plugin login error

I have been able to connect, send and receive messages to facebook xmpp chat server from the Flash IDE publishing as an AIR application. However when I put this SWF in the browser the same working code now returns a 401 | Not Authorized error. I’m wondering if anyone has had similar issues relating to using the library in AIR vs in Flash Player browser plugin. Are there any restrictions or changes from their implementation or functionality?

Here’s the working code for facebook XMPP communication (they are all executed after getting the token from the login response)

private var xmpp:XMPPTLSConnection; public function ChatLogin():void{
          XFacebookPlatform.fb_access_token=FB.token;
          XFacebookPlatform.fb_app_id=FB.appID;
          if (!xmpp) xmpp = new XMPPTLSConnection();           xmpp.tls = true;
          xmpp.useAnonymousLogin = false;
          xmpp.username = FB.apicache.me.id;
          xmpp.server  = "chat.facebook.com";
          xmpp.port = 5222;            xmpp.enableSASLMechanism( XFacebookPlatform.MECHANISM, XFacebookPlatform );           xmpp.addEventListener(LoginEvent.LOGIN, ChatHandler);
          xmpp.addEventListener(XIFFErrorEvent.XIFF_ERROR, ChatHandler);
          xmpp.addEventListener(IncomingDataEvent.INCOMING_DATA, ChatHandler);
          xmpp.addEventListener(MessageEvent.MESSAGE, ChatHandler);
          xmpp.addEventListener(PresenceEvent.PRESENCE, ChatHandler);
          xmpp.addEventListener(ConnectionSuccessEvent.CONNECT_SUCCESS,ChatHandler);
          xmpp.connect(0); } private function ChatHandler(event:*):void{      if (event.type=='error') trace ('FB XMPP', event.errorCode+' | '+event.errorMessage+'|'+event.errorCondition+' | '+event.errorType);
     if (event.type=="login"){      }
     if (event.type=="message"){
          var ms:Message=event.data;
          if (ms.state=='active'){
               trace('FB XMPP FROM',String(ms.from).split('@')[0].substr(1));
               trace('FB XMPP STATE',ms.state);
               trace('FB XMPP BODY',ms.body);
          }
     }
}