views:

108

answers:

1

I am having a problem very similar to this question here: Can I use NSURLCredentialStorage for HTTP Basic Authentication?

The author of that question accepted an answer but later posted that the solution code was returning NSURLErrorUserCancelledAuthentication errors. I am using DIGEST authentication, but otherwise my code is doing the same thing, and returns the same error.

I do not want to send the username and password in cleartext, so I definitely don't want to simply tack the username and password onto the front of the URL. Is there some way to get NSURLConnection's sendSynchronousRequest:returningResponse:error: method to consult the shared NSURLCredentialStorage? It sounds like the type of thing a category would be good for, but I haven't the faintest idea of how I would do it--it sounds like I'd have to completely reimplement the sendSynchronousRequest:returningResponse:error: method to get it to work.

How can I perform a synchronous URL connection that consults the shared NSURLCredentialStorage?

A: 

This may not entirely answer your question, but: synchronous fetches via NSURLConnection have a host of problems (authentication being the least one), and if at all possible you should really restructure your app to use the asynchronous API instead, which will most likely not have the problem you see regarding authentication.

millenomi
Oh, really? What sort of problems are we talking about, here? I really do need the app to wait for the connection to return...
Nate Thorn
I ended up doing just this--I restructured my app a bit to use the asynchronous API. It's not really my ideal solution, but it works. :)
Nate Thorn