Topic
7 replies Latest Post - ‏2013-01-15T10:57:31Z by IdanAdar
SystemAdmin
SystemAdmin
2327 Posts
ACCEPTED ANSWER

Pinned topic Authentication from a native iOS app

‏2013-01-11T16:35:14Z |
Is there any documentation detailing the use of Worklight API for iOS for authentication?

Looking through the headers, I can see that there are four potential challenge handlers: BaseChallengeHandler, ChallengeHandler, WLChallengeHandler and BaseDeviceAuthChallengeHandler. The choice of names looks strange to me, and the inheritance relationships are quite interesting as well.

Is this something ready to use, or a work in progress? Could at least some comments be added to the header files?
  • christianIBM
    christianIBM
    78 Posts
    ACCEPTED ANSWER

    Re: Authentication from a native iOS app

    ‏2013-01-11T16:40:25Z  in response to SystemAdmin
    Theres a whole section dedicated to auth here :

    http://www.ibm.com/developerworks/mobile/worklight/getting-started/#setup

    and I would start with the first module :

    ftp://public.dhe.ibm.com/software/mobile-solutions/worklight/docs/v505/Module_20_-_Authentication_Concepts.pdf

    -Worklight Development Team, iOS-Christian Linares
    • SystemAdmin
      SystemAdmin
      2327 Posts
      ACCEPTED ANSWER

      Re: Authentication from a native iOS app

      ‏2013-01-11T17:16:49Z  in response to christianIBM
      I've read quite attentively modules 20, 21 and 22. They are explaining how to do authentication from an HTML5 app, and I've done all the necessary coding on the server side. I also tried to guess how to do on the native iOS client something similar to what is shown for JavaScript API. However, the differences between JavaScript and Objective-C are quite substantial, and at the moment I am stuck trying to figure out how to use the different challenge handlers that come with Worklight API for iOS, and their methods.

      I have a perfectly working native iOS app which uses Worklight API to retrieve data from the server. Now I want to make the adapter procedure I am using authenticated.
  • IdanAdar
    IdanAdar
    741 Posts
    ACCEPTED ANSWER

    Re: Authentication from a native iOS app

    ‏2013-01-11T17:47:27Z  in response to SystemAdmin
    Alexander,
    Have you taken a look at the Worklight API for iOS documentation? there are some code snippets there for using authentication.

    ftp://public.dhe.ibm.com/software/mobile-solutions/worklight/docs/v505/wl_objcref_ios.pdf

    Idan Adar
    QA Engineer
    IBM Worklight Mobile Platform
    • SystemAdmin
      SystemAdmin
      2327 Posts
      ACCEPTED ANSWER

      Re: Authentication from a native iOS app

      ‏2013-01-14T09:55:11Z  in response to IdanAdar
      Aha, thanks a lot, this is exactly what I was hoping to find.
    • SystemAdmin
      SystemAdmin
      2327 Posts
      ACCEPTED ANSWER

      Re: Authentication from a native iOS app

      ‏2013-01-14T12:35:16Z  in response to IdanAdar
      Well, I managed to do the job done, after reading the whole document. However, I have a strong feeling that this is more like a draft than a completed document.

      Here is why:

      Example 1: calling a back-end service that does not require authentication.

      This one is good. I've done that, it works. There are some typos in the code (see below), but that's minor.

      Example 2: calling a back-end service that requires authentication

      Okay, this is where I am going to find the answers for all my questions, right? Wrong! The code that follows is an (substantially) abbreviated version of Example 1, with no authentication shown whatsoever.

      Fortunately, the API description which follows contains enough information to figure out what to do.

      There are also a few mistakes in this document. Here is what I found:

      1. WLClient sharedInstance wlConnectWithDelegate:connectDelegate;

      This won't compile. The code should be:

      [WLClient sharedInstance] wlConnectWithDelegate:connectDelegate;

      This mistake is repeated throughout the document.

      2. Page 8 says: "If the call succeeds, onInvokeProcedureSuccess is called. If it fails, onInvokeProcedureFailure is called". Well, WLDelegate doesn't have any of these methods, it only has onSuccess and onFailure.

      I also have a few suggestions.

      1. Throughout the document, the following code is used:

      MyConnectDelegate new;

      It's okay, it will work, but it is considered to be a bad style in Objective-C programming and so is hardly appropriate in an official document. The better way (style-wise) to write the same is:

      [MyConnectDelegate alloc] init;

      2. I believe these days anyone doing iOS development is using one of the latest versions of Xcode, and so a new, significantly less verbose syntax can be used. For example, this bunch of code:

      [invocationData setParameters: ;

      Can be written like this:

      invocationData.parameters = @;

      Hope this helps.

      Alexander
      • SystemAdmin
        SystemAdmin
        2327 Posts
        ACCEPTED ANSWER

        Re: Authentication from a native iOS app

        ‏2013-01-14T12:39:45Z  in response to SystemAdmin
        Oooops... I wish I could edit my post - the code part of it was mutilated and doesn't make any sense. Mut the rest of the text should be fine :) Thanks everyone for your help!

        Alexander
  • IdanAdar
    IdanAdar
    741 Posts
    ACCEPTED ANSWER

    Re: Authentication from a native iOS app

    ‏2013-01-15T10:57:31Z  in response to SystemAdmin
    Alexander,
    Thank you for the comments! We have opened a work item and will be updating the documentation.

    Thanks again,

    Idan Adar
    QA Engineer
    IBM Worklight Mobile Platform