Topic
  • 1 reply
  • Latest Post - ‏2013-02-10T08:25:46Z by IdanAdar
SystemAdmin
SystemAdmin
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
    IdanAdar
    741 Posts

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

    ‏2013-02-10T08:25:46Z  
    Hi,

    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: https://www.ibm.com/developerworks/mobile/worklight/getting-started/#authentication

    And more specifically: ftp://public.dhe.ibm.com/software/mobile-solutions/worklight/docs/v505/Module_20_-_Authentication_Concepts.pdf ftp://public.dhe.ibm.com/software/mobile-solutions/worklight/docs/v505/Module_22_-_Adapter_Based_Authentication.pdf

    ---
    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.
    https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14937476

    Idan Adar
    QA Engineer
    IBM Worklight Mobile Platform