setBasicAuthentication Method

This function will set header data required for basic authentication over the Internet.

intel.xdk.device.setBasicAuthentication(domain,username,password)

Description:

This function will set header data required for basic authentication over the Internet. It requires the domain and realm of the server it will make the request to as well as the appropriate username and password credentials. This method is not available on all platforms.

Platforms:

Parameters:

  • domain: The domain and realm of the server to make the request to.
  • username: The appropriate username for the authentication request.
  • password: The appropriate password for the authentication request.

Example:


intel.xdk.device.setBasicAuthentication('api.twitter.com', username, password);

try
{
    xmlhttp = new XMLHttpRequest(); // instantiate XMLHttpRequest
}
catch (err)
{
    alert("Error initializing XMLHttpRequest.\n"+ err); 
    return;
}

xmlhttp.onreadystatechange = function()
{
    alert(xmlhttp.status + "   " + xmlhttp.readyState);
    if (xmlhttp.readyState == 4) 
    {
        if(xmlhttp.status == 200)
        {
            try { RequestResponse(url,true,xmlhttp.responseText); } catch(e) {}
        }

    }
}

try
{
   xmlhttp.open('GET', url);      
}
catch (err)
{
    alert("XMLHttpRequest.open() failed.\n"+err.message + " \n URL : " + url); 
    return;
}

xmlhttp.send(strData);
            
For more complete information about compiler optimizations, see our Optimization Notice.