Skip to main content
October 12, 2011
Question

Air for iOS connecting to sharepoint

  • October 12, 2011
  • 1 reply
  • 739 views

I am looking to download a text file from a 2007 Sharepoint site that is set up on an HTTPS secured server.  I am using the URLLoader function.  I have searched all over google, but I can't find a way to pass the login credentials through the interface to be able to download the file.  If I test the application on either a mac or windows pc, it works fine.  The app prompts me for my login information and I am good to go.  Once it is compiled into an application for both Android or iOS, it does not work.  I am never prompted.  The ideal solution would be to pass the information anyway.  Thank you in Advance for your help.

/* Load External Data */

var nTextLoader:URLLoader = new URLLoader();

nTextLoader.dataFormat=URLLoaderDataFormat.VARIABLES;

var nTextURLRequest:URLRequest = new URLRequest("https://Yourlink.com/data.txt");

nTextLoader.addEventListener(Event.COMPLETE, nCompleteHandler);

function nCompleteHandler(event:Event):void

{

          var textData:String = new String(nTextLoader.data);

          trace(event.target.data.update_dt);

          gphSuccess = true;

          Update_dt = event.target.data.update_dt;

          gotoAndPlay(2);

}

nTextLoader.load(nTextURLRequest);

Thanks for your help.  I am really stuck at the moment.

This topic has been closed for replies.

1 reply

October 13, 2011

You can either use api setLoginCredentialsForHost or can add authorization header to your URL request. Both can handle the authorization without showing the popup.

You can use Authorization header as shown below

// loginID and password

var loginID:String = "guest";

var loginPasswd:String = "guest";

var encodedUsrPassword:String = Base64.encode( loginID + ":" + loginPasswd);

// for HTTP Basic authentication

var urlStream0:URLStream = new URLStream();

var urlRequest_HTTPBasic:URLRequest = new URLRequest(urlHTTPBasic);

urlRequest_HTTPBasic.authenticate = false; // non-interactive login, don't pop up the login dialog

var urlRequestHeader1:URLRequestHeader = new URLRequestHeader("Authorization", "Basic " + encodedUsrPassword );

urlRequest_HTTPBasic.requestHeaders.push(urlRequestHeader1); // append to existing one

urlStream0.load(urlRequest_HTTPBasic);

or you can use setLoginCredentialsForHost API

URL = http://YourUrlAuthentication; }

var urlRequest:URLRequest;

var urlLoader:URLLoader;

urlRequest = new URLRequest(URL);

urlRequest.authenticate = true;

URLRequestDefaults.setLoginCredentialsForHost(host,userName,passWord);

urlLoader.load(urlRequest);