• 1 reply
  • Latest Post - ‏2013-02-10T08:25:46Z by IdanAdar
2327 Posts

Pinned topic Error in Worklight-based app when using Basic Authentication

‏2013-02-08T14:37:29Z |
I have a worklight app running on Android and iOS that uses Basic Auth to authenticate with a backend server. Authentication is done in JavaScript using ajax. The problem I'm having occurs when a user provides an invalid username and password. In this case, the server responds with a 401 Unauthorized response, but my ajax callbacks are never called and the request eventually times out instead. After some research, I was able to fix this on iOS by adding the 'async : false' parameter to the request, but this didn't change the behavior on iOS. It appears that the server's authentication challenge is getting suppressed or lost. Outside of worklight, this works fine. Any suggestions for how to fix or workaround this? Thank you!
  • IdanAdar
    741 Posts

    Re: Error in Worklight-based app when using Basic Authentication


    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:

    Note: IBM forums are in the process of migrating to a new format. During migration the forums will be frozen and in read-only mode. If you wish to continue this thread discussion please post it on stackoverflow, where the Worklight team and others can respond.

    See the Forum Migration announce post for more details. Thank you.

    Idan Adar
    QA Engineer
    IBM Worklight Mobile Platform