Search code examples
migrationibm-mobilefirst

Can't connect to MobileFirst 7.1 server


We were migrating Worklight 6.2 project to MobileFirst 7.1 project.

We just set connectOnStartup to true.

Our MF7.1 iPhone direct update works fine.

But MF7.1 android app cant connect to worklight server.

We got this info from logcat:

Client registration failed with error: {"responseHeaders":{},"status":403,"responseText":"/-secure-\n{\"reason\":\"App authenticity security check failed\"}/","responseJSON":{"reason":"App authenticity security check failed"},"invocationContext":null}

[/apps/services/api/**/android/init] failure. state: 403, response: undefined

Our authenticationConfig.xml is shown below.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<tns:loginConfiguration xmlns:tns="http://www.worklight.com/auth/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <staticResources>
        <resource id="receiveSMS" securityTest="SubscribeServlet">
            <urlPatterns>/receiveSMS*</urlPatterns>
        </resource>
    </staticResources>
    <securityTests>
        <customSecurityTest name="SubscribeServlet">
            <test realm="wl_directUpdateRealm" step="1"/>
            <test isInternalUserID="true" realm="SubscribeServlet"/>
        </customSecurityTest>
    </securityTests>
    <realms>
        <realm loginModule="rejectAll" name="SubscribeServlet">
            <className>com.worklight.core.auth.ext.HeaderAuthenticator</className>
        </realm>
        <realm loginModule="StrongDummy" name="SampleAppRealm">
            <className>com.worklight.core.auth.ext.FormBasedAuthenticator</className>
        </realm>
    </realms>
    <loginModules>
        <loginModule expirationInSeconds="-1" name="rejectAll">
            <className>com.worklight.core.auth.ext.RejectingLoginModule</className>
        </loginModule>
        <loginModule expirationInSeconds="-1" name="StrongDummy">
            <className>com.worklight.core.auth.ext.NonValidatingLoginModule</className>
        </loginModule>
        <loginModule expirationInSeconds="-1" name="requireLogin">
            <className>com.worklight.core.auth.ext.SingleIdentityLoginModule</className>
        </loginModule>
    </loginModules>
</tns:loginConfiguration>

Our Worklight version is : 7.1.0.00-20151107-1647


Solution

    1. As I have mentioned in your other question: do not use connecOnStartup! Change to WL.Client.connect in your code.

    2. The error clearly shows that it is the app authenticity check that is failing. Despite what you are showing in your authenticationConfig.xml file, are you 100% that you are using or not using app authenticity - please confirm

    3. If you are using app authenticity, follow the tutorial and make sure that you are following it correctly. You need to make sure the wlapp file, the war and the .apk are all in sync, otherwise it will fail.

    4. Make sure you are not doing any adapter request before properly connected to the server. Once connected, then you can invoke any calls to the server (via the onSuccess callback of the connect API).