Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I detect an authentication challenge from a UIWebView?
    primarykey
    data
    text
    <p>I've seen <a href="https://stackoverflow.com/questions/1769888/how-to-display-the-authentication-challenge-in-uiwebview">many</a> <a href="https://stackoverflow.com/questions/3818120/how-to-implement-ntlm-authentication-for-uiwebview?lq=1">questions</a> that ask (and answer) how to supply credentials when you know beforehand that the request requires them.</p> <p>When I load a site that requests an authentication challenge, (responds with HTTP 401), my <code>UIWebViewDelegate</code> only receives the following callbacks: <code>webView:shouldStartLoadWithRequest:navigationType:</code> and sometimes <code>webViewDidStartLoad:</code> (<code>webViewDidStartLoad:</code> seems to be called if I navigate directly to the site, and it seems not to be called if I'm redirected there).</p> <p>By overriding <code>-[NSObject respondsToSelector:]</code>, the <code>UIWebViewDelegate</code> receives some calls to <code>uiWebView:resource:canAuthenticateAgainstProtectionSpace:forDataSource:</code> and <code>uiWebView:resource:didReceiveAuthenticationChallenge:fromDataSource:</code>, which could be useful, but of course those are private API and will probably get my app rejected.</p> <p>I've tested a few different mainstream apps with embedded <code>UIWebView</code>s. So far, only Chrome handles these authentication challenges properly. I've even set up my own server and validated that Chrome only <code>POST</code>s once. Twitter and Tweetbot fail just show the loading screen forever, just like mine. </p> <p>Is there another (probably very hacky) way to detect these authentication challenges other than using a second speculative <code>NSURLConnection</code>? If I make a <code>POST</code> request, that will double-<code>POST</code> everything, which is bad.</p> <p><a href="http://openradar.appspot.com/13748318" rel="nofollow noreferrer">I've added a radar to request an enhancement to UIWebView for this</a>. Please duplicate it.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload