HTTP Basic Authentication with HTTPService Objects in Adobe Flex/AIR

前端 未结 8 1428
梦谈多话
梦谈多话 2020-12-04 14:52

I\'m trying to request a HTTP resource that requires basic authorization headers from within an Adobe AIR application. I\'ve tried manually adding the headers to the request

8条回答
  •  春和景丽
    2020-12-04 15:11

    I had the same problem while consuming HTTP Basic Authenticated Webservice. This is my solution; it works fine:

    private function authAndSend(service:WebService):void
    {
        var encoder:Base64Encoder = new Base64Encoder();
            encoder.insertNewLines = false; 
            encoder.encode("user:password");
        service.httpHeaders = { Authorization:"Basic " + encoder.ToString() };
        service.initialize();
    }
    

    usage

    authAndSend(WebService( aWebServiceWrapper.serviceControl));
    

提交回复
热议问题