Skip to Content
avatar image
Former Member

Kapsel with SMP3.0 SP5 - 401 unauthorised error


We are developing a kapsel application by following this link

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#FATAL#Other####1419920950678000#a92f3828-99e1-484a-aa15-5bbeee93687d#com.olam.logintest#GeneratedMethodAccessor221:invoke########705###Unauthorized#

#2.0#2014-12-30 AuthenticationEntryPoint was set during login attempt. Falling back to HTTP 401 + WWW-Authenticate#

#2.0#2014-12-30 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?



    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:


      #FATAL#Other#GeneratedMethodAccessor221:invoke########673###Unauthorized# AuthenticationEntryPoint was set during login attempt. Falling back to HTTP 401 + WWW-Authenticate#

      ##DEBUG#Registration#Security# 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?



    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.



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

              <script type="text/javascript" charset="utf-8" src="cordova.js"></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": "",




                  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;



                  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





                  function read() {

                      if (!applicationContext) {

                          alert("Register or unlock before proceeding");



                      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"


            , 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) {





                  function errorCallback(e) {

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




                  function register() {

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



                  function unRegister() {

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



                  function logonUnregisterSuccessCallback(result) {

                      alert("Successfully Unregistered");

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

                      applicationContext = null;



                  function lock() {

                      sap.Logon.lock(logonLockSuccessCallback, errorCallback);



                  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);

             = "block";

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

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

                          if (screens[i].id != {

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





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






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

                  <h1>Loading ...</h1>



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


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



              <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>




  • 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


    Add comment
    10|10000 characters needed characters exceeded