I have a Cordova based application that requires Basic Authentication. The authentication is done in JavaScript using AJAX. I am running into an issue where if the user types in invalid credentials, the client is never receiving the 401 Unauthorized response that is sent by the server. Instead, the request times out. I was able to resolve this on iOS by setting the async:false parameter as suggested by this thread: iOS: Authentication using XMLHttpRequest - Handling 401 reponse, but it does not resolve the issue on Android. Any suggestions as to how resolve this? It's not optimal to have users wait for the timeout to know that they entered an invalid password. Thanks in advance!
Asked
Active
Viewed 811 times
0
-
You tagged this question with Worklight. Are you using Worklight authentication? – Raanan Avidor Feb 10 '13 at 07:19
-
We're using Cordova, not Worklight. – user2054963 Feb 11 '13 at 15:16
-
Please post your html file. Probably the Content Security Policy is blocking the response. – anirus Sep 23 '16 at 15:46
1 Answers
0
Judging from the same question in the IBM developerWorks forum http://www.ibm.com/developerworks/forums/post!reply.jspa?threadID=470690, this seems to be a Worklight-related question.
====
The Basic Authenticator is not meant for use in the context of Mobile applications. For this, I would recommend using adapter-based authentication.
With adapter-based authentication, you also have onSuccess and onFailure in addition to timeout. Thus, if providing incorrect credentials, you will not have to wait for the timeout, rather you will get onFailure.
See the following topics in IBM Worklight's Getting Started page:
And more specifically:

Idan Adar
- 44,156
- 13
- 50
- 89
-
-
I removed the Worklight tag. Given that Worklight uses Cordova I was wanting to expand the audience. Apologies. – user2054963 Feb 12 '13 at 20:46