Skip to Content
avatar image
Former Member

Kapsel with SMP3.0 SP5 - 401 unauthorised error

Hi,

We are developing a kapsel application by following this link

http://scn.sap.com/docs/DOC-49592

we have declared the authentication as HTTPs authentication with the odata end point  and SSO Mechanism as Technical User Basic(username,password as the odata endpoint credentials)

After entering the credentials in the login screen We are getting a 401 unauthorised error

The following is the log trace:

#2.0#2014-12-30 06:29:11.042#+0:00#ERROR#Registration#401##Other#1419920950678002#a92f3828-99e1-484a-aa15-5bbeee93687d#com.olam.logintest#com.sap.mobile.platform.server.online.filter.application.AbstractSMPApplicationSettingsHandler:doFilter########705###Unauthorized#

#2.0#2014-12-30 06:29:11.042#+0:00#FATAL#Other####1419920950678000#a92f3828-99e1-484a-aa15-5bbeee93687d#com.olam.logintest#GeneratedMethodAccessor221:invoke########705###Unauthorized#

#2.0#2014-12-30 06:29:11.04#+0:00#DEBUG#Registration###Security#1419920950678001#a92f3828-99e1-484a-aa15-5bbeee93687d#com.olam.logintest#com.sap.mobile.platform.server.foundation.security.filter.AuthenticationFilter:doFilter########705###No AuthenticationEntryPoint was set during login attempt. Falling back to HTTP 401 + WWW-Authenticate#

#2.0#2014-12-30 06:29:10.794#+0:00#DEBUG#Registration###Security#1419920950678000#a92f3828-99e1-484a-aa15-5bbeee93687d#com.olam.logintest#com.sap.mobile.platform.server.foundation.security.filter.AuthenticationFilter:doFilter########705###authfilter-1: Security Configuration set to: 'LoginHttp'#

Kindly advise.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Dec 30, 2014 at 07:18 AM

    Hi Dinesh,

    Are you able to ping application id in the admin cockpit? Are you able to see "Backend system reached successfully" response?

    Have you tried with register2.html index file as attached in this link Getting Started with Kapsel - Part 2 -- Logon? Are you able to register to SMP server?

    As your OData Endpoint is HTTPS, have you imported certificate in SMP3 keystore?

    Regards,

    JK

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Jitendra Kansal

      HI jitendra,

      the backend which we are using is sap and the odata url is generated with netweaver gateway.

      We have tried giving the SSO mechanism as basic

      and the odata url in smp (backend url and authentication also)

      But still we are having the 401 error.

      in SMP logs we are seeing this trace:

      #ERROR#Registration#401#Other#

      com.sap.mobile.platform.server.online.filter.application.AbstractSMPApplicationSettingsHandler:doFilter#673#Unauthorized

      #FATAL#Other#GeneratedMethodAccessor221:invoke########673###Unauthorized#

      #DEBUG#Registration#Security#com.sap.mobile.platform.server.foundation.security.filter.AuthenticationFilter:doFilter#673##No AuthenticationEntryPoint was set during login attempt. Falling back to HTTP 401 + WWW-Authenticate#

      ##DEBUG#Registration#Security#

      #com.sap.mobile.platform.server.foundation.security.filter.AuthenticationFilter:doFilter########673###authfilter-1: Security Configuration set to: 'NHttp'#

  • Dec 31, 2014 at 05:40 AM

    Former Member

    Can you share the latest settings screenshot for application id created in admin cockpit? Backend details, Authentication?

    Are you trying with register3.html file as given in the document?

    Can you share latest index.html file that you are trying with?

    Regards,

    JK

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Jitendra Kansal

      Jitendra Kansal

      yes. we have tried with register3.html as given in the document.

      Please find below the index.html.

      <html>

          <head>

              <script src="datajs-1.1.2.min.js"></script>

              <script type="text/javascript" charset="utf-8" src="cordova.js"></script>

              <script>

                  applicationContext = null;

                 

                  window.onerror = onError;

                 

                  var appId = "com.atest.login"; // app id

                 

                  // Optional initial connection context

                  var context = {

                      "serverHost": "", //Our SMP 3.0 server IP here

                      "https": "false",

                      "serverPort": "8080",

                      "user": "", // USER NAME for the OData Endpoint here

                      "password": "",  // PASSWORD for the OData Endpoint here

                                            //once set can be changed by calling sap.Logon.changePassword()

                      "communicatorId": "REST",

                      "passcode": "",  //note hardcoding passwords and unlock passcodes are strictly for ease of use during development

                   

                      "unlockPasscode": "",

                      "passcode_CONFIRM":"",

                      "ssoPasscode":""

                  };

                  function onError(msg, url, line) {

                      var idx = url.lastIndexOf("/");

                      var file = "unknown";

                      if (idx > -1) {

                          file = url.substring(idx + 1);

                      }

                      alert("An error occurred in " + file + " (at line # " + line + "): " + msg);

                      return false; //suppressErrorAlert;

                  }

                 

                  function init() {

                      if (sap.Logger) {

                          sap.Logger.setLogLevel(sap.Logger.DEBUG);  //enables the display of debug log messages from the Kapsel plugins.

                          sap.Logger.debug("Log level set to DEBUG");

                      }

                     

                      sap.Logon.init(logonSuccessCallback, logonErrorCallback, appId, context);

                      console.log("init completed");

                  }

                 

                  function logonSuccessCallback(result) {

                      console.log("logonSuccessCallback " + JSON.stringify(result));

                      applicationContext = result;

                      showScreen("MainDiv");

                  }

                  function logonErrorCallback(error) {   //this method is called if the user cancels the registration.

                      console.log("An error occurred:  " + JSON.stringify(error));

                      if (device.platform == "Android") {  //Not supported on iOS

                          navigator.app.exitApp();

                      }

                  }

             

                  function read() {

                      if (!applicationContext) {

                          alert("Register or unlock before proceeding");

                          return;

                      }

                      sUrl = applicationContext.applicationEndpointURL + "/zuname?BNAME=%27IN_USER%27";  //JSON format is less verbose than atom/xml

                      var oHeaders = {};

                      oHeaders['Authorization'] = "Basic " + btoa(applicationContext.registrationContext.user + ":" + applicationContext.registrationContext.password);

                      oHeaders['X-SMP-APPCID'] = applicationContext.applicationConnectionId;

                     

                      var request = {

                          headers : oHeaders,

                          requestUri : sUrl,

                          method : "GET"

                      };

                      OData.read(request, readSuccessCallback, errorCallback);

                  }

                 

                  function readSuccessCallback(data, response) {

                      var carrierTable = document.getElementById("carrierTable");

                     

                      for (var i = data.results.length -1; i >= 0; i--) {

                          var row = carrierTable.insertRow(1);

                          var cell1 = row.insertCell(0);

                          var cell2 = row.insertCell(1);

                          cell1.innerHTML = data.results[i].Ebeln;

                          cell2.innerHTML = data.results[i].Ekgrp;

                      }

                  }

                 

                  function clearTable() {

                      var carrierTable = document.getElementById("carrierTable");

                      while(carrierTable.rows.length > 1) {

                          carrierTable.deleteRow(1);

                      }

                  }

                 

                  function errorCallback(e) {

                      alert("An error occurred: " + JSON.stringify(e));

                      showScreen("MainDiv");

                  }

                 

                  function register() {

                      sap.Logon.init(logonSuccessCallback, logonErrorCallback, appId, context);

                  }

                 

                  function unRegister() {

                      sap.Logon.core.deleteRegistration(logonUnregisterSuccessCallback, errorCallback);

                      clearTable();

                  }

                  function logonUnregisterSuccessCallback(result) {

                      alert("Successfully Unregistered");

                      console.log("logonUnregisterSuccessCallback " + JSON.stringify(result));

                      applicationContext = null;

                  }

                 

                  function lock() {

                      sap.Logon.lock(logonLockSuccessCallback, errorCallback);

                      clearTable();

                  }

                  function logonLockSuccessCallback(result) {

                      console.log("logonLockSuccessCallback " + JSON.stringify(result));

                      applicationContext = null;

                      showScreen("LockedDiv");  //sap.Logon.unlock(function () {},function (error) {});

                      //alternatively show the unlock screen

                  }

                  function unlock() {

                      sap.Logon.unlock(logonSuccessCallback, errorCallback);

                  }

                 

                  function showScreen(screenIDToShow) {

                      var screenToShow = document.getElementById(screenIDToShow);

                      screenToShow.style.display = "block";

                      var screens = document.getElementsByClassName('screenDiv');

                      for (var i = 0; i < screens.length; i++) {

                          if (screens[i].id != screenToShow.id) {

                              screens[i].style.display = "none";

                          }

                      }

                  }

                 

                  document.addEventListener("deviceready", init, false);

                 

                  </script>

             

          </head>

          <body>

              <div class="screenDiv" id="LoadingDiv">

                  <h1>Loading ...</h1>

              </div>

             

              <div class="screenDiv" id="LockedDiv" style="display: none">

                  <h1>Locked</h1>

                  <button id="unlock" onclick="unlock()">Unlock</button>

              </div>

             

              <div class="screenDiv" id="MainDiv" style="display: none">

                  <h1>Logon Sample 3</h1>

                  <button id="register" onclick="register()">Register</button>

                  <button id="read" onclick="read()">Read</button>

                  <button id="unregister" onclick="unRegister()">Unregister</button>

                  <button id="lock" onclick="lock()">Lock</button>

                  <button id="unlock" onclick="unlock()">Unlock</button>

                  <table id="carrierTable"><tr><th>Carrier ID</th><th>Carrier Name</th></tr></table>

              </div>

          </body>

      </html>

  • avatar image
    Former Member
    Mar 15, 2015 at 06:37 AM

    Hi Dinesh..

        Did u manage to solve the error.

        am also facing same issue

        

    com.sap.mobile.platform.server.online.filter.application.AbstractSMPApplicationSettingsHandler:doFilter########705###Unauthorized#

    Add comment
    10|10000 characters needed characters exceeded