Basic authentication fails in ios cordova

I tried to make an ajax call with basic authentication in a hybrid ios mobile application. An Ajax call does not return anything that it simply does not succeed or fail. But the same ajax call successfully starts with android.

While I checked the outgoing request with wirehark, I found that the authentication header was missing, and 401 was returned from my server, and on the next call, the authentication header was sent along with the request, which returned 301. But it works with android

The same api works fine from my dev server in ios, but doesn't work on my prod server

Any suggestions are welcome.

+3
angularjs authentication ajax ios cordova
source share
2 answers

I am using cordova 4.2.0.

I noticed that in the case of a 401 response with the title "WWW-Authenticate: Basic", the IOS / UIWebView seems to swallow the response, rather than transferring it back to the application layer, which prevents the service from ever responding. Perhaps this prevents pop-ups.

In any case, the behavior is completely unexpected!

edit: I found a cord write error report for this problem: https://issues.apache.org/jira/browse/CB-2415

+1
source share

This is similar to the solution with the Cordoba platform iOS 4.X and higher. I just upgraded the old application from using UIWebView to WKWebView, and this problem no longer occurs, and we could fix a relatively painful workaround (using synchronous calls).

0
source share

All Articles