Important! A new Community experience launched on September 26, 2017. Read more about it here or continue to Base Camp.
Voting: 
Vote up!
2 Votes
26 Replies
Answered

kony client for mobilefabric on Kony Studio

Question asked by akankshya.agarwal on Feb 04, 2016 14:43 EST

Hello, I am new to Kony and currently evaluating the 90 day trial of MobileFabric and Kony Studio. I have created a MobileFabric app that utilizes a basic identity service using Kony User Repository (username, password). This app is published on the mobilefabric runtime environment and cURL responds as expected to the login service. I have a sample login page created in Kony Studio (built for native Android). On click of the login button, I am trying to invoke the created identity service on my mobilefabric instance using the below code: onClick event of button:     var appkey = my-app-key;     var appsecret = my-app-secret;     var serviceURL = "https://<auth.konycloud.com>/appconfig";     var client = new kony.sdk();     client.init(appkey, appsecret, serviceURL, function(response) {         kony.print("Init success");     }, function(error) {         kony.print("Init Failure");     });     // Sample code to authenticate to Kony MobileFabric Client     var authClient = null;     var providerName = "userstore";     var username = frmLogin.usrName.text;     var password = frmLogin.psWord.text;     try {         authClient = client.getIdentityService(providerName);     } catch (exception) {         kony.print("Exception" + JSON.stringify(exception));     }     authClient.login({         "userid": username,         "password": password     }, function(response) {         kony.print("Login success" + JSON.stringify(response));     }, function(error) {         kony.print("Login failure" + JSON.stringify(error));     }); However, the above code crashes on line authClient.login, saying that "Cannot call method 'login' of undefined". I tried to debug with breakpoints, and it turns out authClient was not set at line authClient = client.getIdentityService because maybe client itself failed to initialize. Can anyone help me with this basic functionality of login using Identity service? Thanks, Abhishek

Vote up!
0 votes
Vote down!

Hi Abhishek,

The code looks ok to me. As you suspect, I too believe that something went wrong in SDK initialization. Could you recheck initialization parameters (say appsecret, appkey and serviceURL) and try again by putting below alert statements in success and failure methods of initialization. These alert statements may help you to debug issue.

  •     Success : alert("success in init" + JSON.stringify(res));
  •     Failure :  alert("failure in init" + JSON.stringify(res));

Thanks,

SubbaReddy.

Replied by: Feb 05, 2016 04:34 EST
Vote up!
0 votes
Vote down!

Hi Abhishek,

Is the Init Success callback being invoked? You should see an init success message in the logs if that's the case.

Replied by: Feb 05, 2016 04:36 EST
Vote up!
0 votes
Vote down!

Hi Ajay,

No Init success callback is not getting invoked. What could be the problem with initialization? I am simply following the instructions in the user guide and have double-checked the app keys and service URl.

Any ideas?

Thanks,

Abhishek

Replied by: Feb 08, 2016 04:21 EST
Vote up!
0 votes
Vote down!

Anyone?

Replied by: Feb 14, 2016 23:58 EST
Vote up!
0 votes
Vote down!

Hi Abhishek,

Did you try Subbareddy's code snippet? What is the error that shows up in the error dialog when the code goes into the error callback? We need to see what the error is, and his alerts will help with debugging further.

Thanks,

Ajay

Replied by: Feb 15, 2016 00:57 EST
Vote up!
0 votes
Vote down!

Hi Ajay,

I tried putting Subbareddy's code snippet in the initialization callbacks. However, I don't see any alerts getting triggered. 

Is the init method a synchronous or asynchronous call? If it is asynchronous, then I might be doing it wrong. Because as soon as I click the button, I get the error on line authClient.login, saying "Cannot call method 'login' of undefined". 

Do you have a working sample app for the login functionality using Kony User Repository and Kony Studio client sdk?

Please let me know.

Thanks,

Abhishek

Replied by: Feb 15, 2016 01:27 EST
Kony Answered Certificate
Vote up!
0 votes
Vote down!

Hi Akankshya,

The init method is an asynchronous call.So you should call the login function in the success callback of the init function.This is the code which should work for you:

var appkey = my - app - key;
var appsecret = my - app - secret;
var serviceURL = "https://<auth.konycloud.com>/appconfig";
var client = new kony.sdk();

client.init(appkey, appsecret, serviceURL, function(response) {
    kony.print("Init success");
    // Sample code to authenticate to Kony MobileFabric Client
    var authClient = null;
    var providerName = "userstore";
    var username = frmLogin.usrName.text;
    var password = frmLogin.psWord.text;

    try {
        authClient = client.getIdentityService(providerName);
    } catch (exception) {
        kony.print("Exception" + JSON.stringify(exception));
    }
    authClient.login({
        "userid": username,
        "password": password
    }, function(response) {
        kony.print("Login success" + JSON.stringify(response));
    }, function(error) {
        kony.print("Login failure" + JSON.stringify(error));
    });
}, function(error) {
    kony.print("Init Failure");
});

Please let me know if there are any issues.

Thanks,

Bharath

Answered by: Feb 15, 2016 01:59 EST
Vote up!
0 votes
Vote down!

Hi Bharath,

Thank you so much. It is working now!

I had another question regarding integration services hosted on Kony MobileFabric

I have published an integration service on Kony MobileFabric. Thing is, now I want to invoke this service from the front-end developed using Visualizer + Kony Studio. Within Studio, I saw that there is an option to invoke services in the Event Editor usign Action Sequence. However, when I select the option I do not see the integration service I created in the drop down. Also, under Application Properties -> MobileFabric, I am unable to see the service there.

Would you be able to throw some light on that or point me in the right direction?

Thanks again

Akankshya

Replied by: Feb 15, 2016 06:55 EST
Vote up!
0 votes
Vote down!

Did you add the mobilefabric url in the preferences?Also,did you link the studio app to the mobile fabric app?

Thanks,

Bharath

Replied by: Feb 15, 2016 07:37 EST
Vote up!
0 votes
Vote down!

I don't think I came across any such thing in the documentation so far or maybe I am not looking in the right place. Could you please point me to the right document that talks about linking studio and mobilefabric apps and also where to put the mobilefabric url in preferences?

I thought the Kony Server tab under Application Properties is where I need to select the mobilefabric url - which currently points to the correct url. Is that the place you are talking about?

Appreciate your help.

Thanks,

Akankshya

Replied by: Feb 15, 2016 08:26 EST
Vote up!
0 votes
Vote down!

Hi Akankshya,

For invoking that service you need to link the studio application to the mobile fabric application.In the project properties,do you see any tab named MobileFabric?If Yes,select the mobile fabric app from the list and you will be able to see your variables.

Thanks,

Bharath

Replied by: Feb 16, 2016 02:02 EST
Vote up!
0 votes
Vote down!

Hi Bharath,

That's exactly what my concern was. I do not see my MobileFabric app listed under the MobileFabric tab. 

Anything I am doing wrong while publishing the app to the mobilefabric runtime? I can see that the app has been published with the identity and integration service that I have defined. But the app doesn't show up in the project properties.

Please help.

Thanks,

Abhishek

Replied by: Feb 16, 2016 02:33 EST
Vote up!
0 votes
Vote down!

Hi Abhishek,

How did you login to the studio?Is it through help->About kony license->manage license or did you use license file to login to the studio?

Thanks,

Bharath

Replied by: Feb 16, 2016 05:28 EST
Vote up!
0 votes
Vote down!

Hi Bharath,

We logged in through Help -> About License -> Manage license. We are using the trial license at the moment.

Thanks,

Abhishek

Replied by: Feb 16, 2016 07:00 EST
Vote up!
0 votes
Vote down!

Attached are the two settings in application properties that show the MobileFabric URL and the services tab. As you can see the MobileFabric app services do not show up in the MobileFabric tab even when the Kony server is set to the mobilefabric URL.

Please let me know.

Replied by: Feb 16, 2016 07:21 EST
Vote up!
0 votes
Vote down!

Forgot the attachment. PFA

Replied by: Feb 16, 2016 07:23 EST
Vote up!
0 votes
Vote down!

Is the app published in the same cloud as mentioned in the server details above?The apps won't show up if there are published elsewhere.

Thanks,

Bharath

Replied by: Feb 16, 2016 07:33 EST
Vote up!
0 votes
Vote down!

The app is published in the same cloud as what you see in the Kony Server settings. In fact, we have the permission to create only one cloud instance in the trial license.

Replied by: Feb 16, 2016 07:55 EST
Vote up!
0 votes
Vote down!

Hi Bharath,

Any idea how we can solve this?

Thanks,

Akankshya

Replied by: Feb 18, 2016 04:35 EST
Vote up!
0 votes
Vote down!

Hi Akankshya,

Do you see any errors in the console which logging in or while connecting to mobile fabric application?

Thanks,

Bharath

Replied by: Feb 18, 2016 05:44 EST
Vote up!
0 votes
Vote down!

Hi Bharath,

One issue I see once in a while is this "peer not authenticated" error. 

Also when I try to refresh Kony Server details, it throws the same error message (see attached).

Do you think these two could be related?

Thanks,

Akankshya

Replied by: Feb 18, 2016 09:33 EST
Vote up!
0 votes
Vote down!

Hi Akankshya,

This issue could be because of the "peer not authenticated" error.Just try it once that issue gets fixed.

Thanks,

Bharath

Replied by: Feb 19, 2016 00:16 EST
Vote up!
0 votes
Vote down!

And exactly how would I fix the "peer not authenticated" issue? :)

Please understand that we are trying to evaluate Kony products so that we can pitch a story to our management in order to purchase the license. If we simply run out of the 90-day trial period running behind fixing such issues, we will end up nowhere in our evaluation.

Appreciate your timely inputs on the same.

Thanks,

Akankshya

Replied by: Feb 19, 2016 01:58 EST
Vote up!
0 votes
Vote down!

FYI

My android application is throwing the "No Peer Certificate" error in the DDMS logs during client initialization. I have attached the log file for your reference.

There's something going on with our mobilefabric account and I am not able to understand what it is.

Thanks,

Akankshya

Replied by: Feb 19, 2016 05:29 EST
Vote up!
0 votes
Vote down!

Hi Akankshya,

Thank you for contacting Kony.

Apologies for the delay in response.

To over come this issue at the development level, Kony has provided application level properties which can help you make the service call even if the server does not have proper SSL certificates. Set the property 'Allow Self Signed Certificate' to TRUE to bypass these errors.

Please note that this is not a Kony issue, rather the behavior or native OS's when they are talking to a server with improper certificate.

Note : Please do NOT use this suggestion in the production environments. Always use a valid and proper certificate.

When you are connecting to a URL from the application and that application domain has a valid certificate issued by Valid certificate authority, Then we need not to bundle the certificate in the app binary. Our Native OS will validate against the known or installed CA in the device. If the certificate is issued by Known CA to the device, Then the HTTPS connection will be established.

We believe that this error is coming because you are using either a self-signed certificate OR a certificate which is not proper. Please refer the below links which can help you understand this.

https://groups.google.com/forum/#!topic/mobile-couchbase/DC9HzIBYKyI
http://dev.kafol.net/2014/05/SSLPeerUnverifiedException-No-peer-certificate.html

You can also verify your certificate using 3rd party tools like https://www.sslshopper.com/ssl-checker.html

Please use the above tool and verify your certificates.

Hope to have answered your query.

Thank you

Rashmi

Replied by: Apr 15, 2016 02:39 EDT
Gold
Vote up!
0 votes
Vote down!

Hi Akankshya,

Is your issue solved by following the Rashmi's steps?

Are you able to login to cloud through browser?

Thanks,

Sindhura.

Replied by: Apr 18, 2016 06:34 EDT