title: Connection issues from certain devices
body: <p>Can't connect from device using custom authenticator and ChallengeHandler.</p>
  
  <p>This is from Worklight 6.1.0.2 from an iPod Touch device.  On the worklight server, we see this in the Stack Trace. </p>
  
  <pre><code>klight.console.controllers.UsersController from Application javax.ws.rs.core.Application
  [10/8/14 15:20:04:170 CDT] 0000001c com.worklight.core.auth.impl.LoginContext                    E FWLSE0059E: Login into realm 'NullLoginModule' failed. Invalid gadget request format: /WorkExecution/iphone/my_custom_auth_request_urlnull. Unknown handler path: my_custom_auth_request_url. [project AnywhereWorkManagement]
  com.worklight.gadgets.GadgetRuntimeException: Invalid gadget request format: /WorkExecution/iphone/my_custom_auth_request_urlnull. Unknown handler path: my_custom_auth_request_url
      at com.worklight.gadgets.api.GadgetAP
  </code></pre>
  
  <p>Our challenge handler submits our Authentication information using this Javascript call: </p>
  
  <pre><code>challengeHandler.submitLoginForm(challengeHandler.getAuthURL(), loginOptions, l
  </code></pre>
  
  <p>Where getAuthURL returns the string "/my_custom_auth_request."</p>
  
  <p>Strangely, other devices using the same application and worklight server are allowed to login successfully.  Another weird datapoint is that if we popup the Worklight Settings panel on this iPod Touch device, and update the Worklight server information, the worklight login then seems to succeed.</p>
  
  <p>Wireshark log from the failed connection:</p>
  
  <pre><code>POST /AnywhereWorkManagement/apps/services/api/WorkExecution/iphone/login HTTP/1.1
  Host: mobilenext1.tivlab.austin.ibm.com
  Accept-Language: en_US
  User-Agent: Mozilla/5.0 (iPod touch; CPU iPhone OS 7_1_2 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Mobile/11D257 (367413328)/Worklight/6.1.0.02.20141006-1624
  Content-Length: 71
  x-wl-platform-version: 6.1.0.02.20141006-1624
  X-Requested-With: XMLHttpRequest
  Content-Type: application/x-www-form-urlencoded; charset=UTF-8
  x-wl-app-version: 7.5.1.1
  Accept: text/javascript, text/html, application/xml, text/xml, */*
  Connection: keep-alive
  x-wl-native-version: 1475155033
  x-wl-device-id: 36CDA8F2-F4E9-49D8-8CBB-A250FDC3B8FA
  Cookie: WL_PERSISTENT_COOKIE=ac72a920-b614-423d-8347-e4b5c96a4a1b
  Origin: file://
  Accept-Encoding: gzip, deflate
  
  realm=CustomAuthenticationRealm&amp;isAjaxRequest=true&amp;x=0.7606244247872382HTTP/1.1 503 Service Unavailable
  X-Powered-By: Servlet/3.0
  P3P: policyref="/w3c/p3p.xml", CP="CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE"
  Content-Language: en-US
  Content-Length: 0
  Connection: Close
  Date: Fri, 10 Oct 2014 14:32:15 GMT
  </code></pre>
  
  <p>Then after updating the Custom URL to remove the trailing slash, and relogging in, here's the wireshark log from the successful login:</p>
  
  <pre><code>POST /AnywhereWorkManagement/apps/services/api/WorkExecution/iphone/query HTTP/1.1
  Host: mobilenext1.tivlab.austin.ibm.com
  Accept-Language: en_US
  User-Agent: Mozilla/5.0 (iPod touch; CPU iPhone OS 7_1_2 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Mobile/11D257 (384405120)/Worklight/6.1.0.02.20141006-1624
  Accept-Encoding: gzip, deflate
  Content-Length: 210
  x-wl-platform-version: 6.1.0.02.20141006-1624
  X-Requested-With: XMLHttpRequest
  Content-Type: application/x-www-form-urlencoded; charset=UTF-8
  x-wl-app-version: 7.5.1.1
  Accept: text/javascript, text/html, application/xml, text/xml, */*
  Connection: keep-alive
  x-wl-native-version: 1475155033
  x-wl-device-id: 36CDA8F2-F4E9-49D8-8CBB-A250FDC3B8FA
  Cookie: WL_PERSISTENT_COOKIE=0983cfc8-8526-48c9-99cb-72659cb934b4; JSESSIONID=0000wSxsNgF79M62_UJTNmXKKYC:2e8ee48e-dec4-4c69-b8b4-ad37f839f1be
  Origin: file://
  WL-Instance-Id: okur33g93p35c9j7rvpk1r9g5j
  
  adapter=OSLCGenericAdapter&amp;procedure=getProperties&amp;compressResponse&amp;parameters=%5B%7B%22propertyNames%22%3A%5B%22si.auth.type%22%5D%7D%5D&amp;__wl_deviceCtx=Ar1Cjm4_mo9jpBAA&amp;isAjaxRequest=true&amp;x=0.33572526928037405HTTP/1.1 200 OK
  X-Powered-By: Servlet/3.0
  P3P: policyref="/w3c/p3p.xml", CP="CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE"
  Content-Type: application/json; charset=UTF-8
  Cache-Control: no-cache, no-store, must-revalidate
  Expires: Sat, 26 Jul 1997 05:00:00 GMT
  Content-Length: 93
  Date: Fri, 10 Oct 2014 14:43:15 GMT
  
  
  
  
  
   /*-secure-
      {"isSuccessful":true,"responseID":"1516","properties":{"si.auth.type":"maximo"}}*/POST /AnywhereWorkManagement/apps/services/api/WorkExecution/iphone/my_custom_auth_request_url HTTP/1.1
      Host: mobilenext1.tivlab.austin.ibm.com
      Accept-Language: en_US
      User-Agent: Mozilla/5.0 (iPod touch; CPU iPhone OS 7_1_2 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Mobile/11D257 (384405120)/Worklight/6.1.0.02.20141006-1624
      X-Requested-With: XMLHttpRequest
      Accept: text/javascript, text/html, application/xml, text/xml, */*
      Content-Type: application/x-www-form-urlencoded; charset=UTF-8
      x-wl-app-version: 7.5.1.1
      Connection: keep-alive
      Cookie: WL_PERSISTENT_COOKIE=0983cfc8-8526-48c9-99cb-72659cb934b4; JSESSIONID=0000wSxsNgF79M62_UJTNmXKKYC:2e8ee48e-dec4-4c69-b8b4-ad37f839f1be
      x-wl-device-id: 36CDA8F2-F4E9-49D8-8CBB-A250FDC3B8FA
      Content-Length: 62
      Origin: file://
      Accept-Encoding: gzip, deflate
  
      username=wilson&amp;password=wilson&amp;authType=maximo&amp;langcode=en-USHTTP/1.1 200 OK
      X-Powered-By: Servlet/3.0
      P3P: policyref="/w3c/p3p.xml", CP="CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE"
      Content-Type: application/json; charset=UTF-8
      Cache-Control: no-cache, must-revalidate
      Content-Language: en-US
      Transfer-Encoding: chunked
      Date: Fri, 10 Oct 2014 14:43:15 GMT
  
      19
      {"authStatus":"complete"}
      0
  </code></pre>
  
  <p>I found this in the server logs to correspond with that 503 error from worklight server (I can reproduce by POSTing the same login URL).  However in our Worklight Console, there is only one version of each application listed for iphone.  </p>
  
  <pre><code> [10/10/14 10:37:54:063 CDT] 00000485 com.worklight.gadgets.serving.GadgetAPIServlet               E FWLSE0020E: Ajax request exception: The environment 'iphone' supports multiple versions, therefore you must request it with a version parameter. [project AnywhereWorkManagement]
  [10/10/14 10:37:54:066 CDT] 00000485 com.worklight.gadgets.serving.GadgetAPIServlet               E FWLSE0117E: Error code: 1, error description: INTERNAL_ERROR, error message: FWLSE0069E: An internal error occurred during gadget request  [project AnywhereWorkManagement]The environment 'iphone' supports multiple versions, therefore you must request it with a version parameter., User Identity {wl_authenticityRealm=null, CustomAuthenticationRealm=null, wl_remoteDisableRealm=null, wl_antiXSRFRealm=null, wl_deviceAutoProvisioningRealm=null, wl_deviceNoProvisioningRealm=null, wl_anonymousUserRealm=null}. [project AnywhereWorkManagement] 
  </code></pre>