cancel
Showing results for 
Search instead for 
Did you mean: 

SAPUI5 Logout of SAP GW using standard service

Former Member
0 Kudos

HI Friends

I am trying to see if there is any standard GW OData Service to logout the SAPUI5 session and establish the session when we login again?

I have an issue while I am using SAP Portal to launch GW sapui5 application. And as we are still using SAPEP 7.0, I am launching the SAPUI5 app as a new window. When user closes the SAPUI5 tab/window and logout of SAPEP, again login with another user id , the old session is retained in the SAPUI5 app.

I need a way to logout the SAP GW user when SAPEP is loggedout.

refering the old thread but not sure if this works for SAP GW and SAP EP.

Logout from SAPUI5 / XSJS page | SCN

https://scn.sap.com/community/developer-center/front-end/blog/2014/04/20/logofflogout-function-for-a...

https://help.sap.com/saphelp_uiaddon10/helpdata/en/66/a7a5de69b340c4ac857a5c0d95de6c/content.htm

https://help.sap.com/saphelp_uiaddon10/helpdata/en/8b/d342ae2cca4097b13e30dfba335c09/content.htm

all are using the below simple event to clear


$.ajax({

           type: "GET",

           url: "/sap/public/bc/icf/logoff",  //Clear SSO cookies: SAP Provided service to do that

        });

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

I use below function

$.ajax({

    type: "GET",

    url: "http://<server>:<port>/sap/public/bc/icf/logoff", //Clear SSO cookies: SAP Provided service to do that 

}).done(function(data) { //Now clear the authentication header stored in the browser 

    if (!document.execCommand("ClearAuthenticationCache")) {

        //"ClearAuthenticationCache" will work only for IE. Below code for other browsers 

        $.ajax({

            type: "GET",

            url: "http://<server>:<port>/<serviceURL>", //any URL to a Gateway service 

            username: 'dummy', //dummy credentials: when request fails, will clear the authentication header 

            password: 'dummy',

            statusCode: {

                401: function() {

                    //This empty handler function will prevent authentication pop-up in chrome/firefox 

                }

            },

            error: function() {

                //alert('reached error of wrong username password') 

            }

        });

    }

})

hope this helps

Former Member
0 Kudos

Rajesh, thank you it worked.

Answers (1)

Answers (1)

junwu
Active Contributor
0 Kudos

check this