Basic Authentication within createHTTPClient
happy friday!
Hey I was wondering if there is a basic authentication method for Titanium.Network.createHTTPClient(); as there is for Titanium.UI.createWebView.
I need to connect with a server that has a basic apache auth box that pops up and asks for u/p
I know I can use: http://USER:PASS@URL but I think thats a bit less secure right?
I didnt see anything in the documentation but thought I would ask. Thanks
1 Answer
-
Accepted Answer
Last time I checked there wasn't any built-in support for basic auth in HTTPClient. Fortunately, you can easily set the correct headers yourself:
xhr.setRequestHeader( 'Authorization', 'Basic ' + Ti.Utils.base64encode(username+':'+password));