If your server is password protected, you need to know the authentication scheme used. If your server uses HTTP Basic/Digest authentication, your code above should just work. If your server serves you a HTML page and asks you to type a username/password (aka, HTTP+HTML Form based authentication) you are out of luck, unless you reverse engineer and find a workaround.
Accessing files on password protected server
-
30-11-2021 - |
Question
I've been retrieving documents from a public web server by going to the URL and parsing the HTML tree with TFHpple, like this:
NSData *documentsHTMLData = [NSData dataWithContentsOfURL:myURL];
TFHpple *documentsParser = [TFHpple hppleWithHTMLData:documentsHTMLData];
....
....
The server is now being password protected and I was hoping to still be able to access it, perhaps using MKNetworkKit. I've got as far as:
MKNetworkEngine *myEngine = [[MKNetworkEngine alloc] init];
MKNetworkOperation *user = [myEngine operationWithURLString:myURL];
[user setUsername:@"test" password:@"test"];
[myEngine enqueueOperation:user];
but have no idea where to go from there with MKNetworkKit regarding how to then get access to directory structure.
I was hoping someone here might be able to point me in the right direction. Any ideas greatly appreciated.
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow