{QuickTip} Logout from Dynamics 365 Portals/ PowerApps portals programmatically

Seeing the title of this post, you may be wondering what’s new about this post. After all, you already have a post which shows how to put custom login/ logoff button.

Well,  there is something new here. And that’s why this blog post.

The requirement this time is to logoff without user intervention. And based on certain business logic. Long story short, the user will perform some operation post which he should be signed out and signed in.

Same concept can be used to automatically sign out a user after few minutes of activity although there are other ways to do the same.

Enough of talking, let’s see the code.

var LogOff = new Promise (function(resolve, reject) {
    var xmlHttp = new XMLHttpRequest();
    xmlHttp.open("GET", "<a href="https://https://<portalurl>/account/login/logoff", true);

var LogOff = new Promise (function(resolve, reject) {
    var xmlHttp = new XMLHttpRequest();
    xmlHttp.open("GET", "<a href="https://https://<portalurl>/account/login/logoff", true);

var LogOff = new Promise (function(resolve, reject) {
    var xmlHttp = new XMLHttpRequest();
    xmlHttp.open("GET", "<a href="https://https://<portalurl>/account/login/logoff", true);

var LogOff = new Promise (function(resolve, reject) {
    var xmlHttp = new XMLHttpRequest();
    xmlHttp.open("GET", "<a href="https://https://<portalurl>/account/login/logoff", true);

No matter what authentication you are using, this will work. And the user will be required to sign in again.

Hope this helps!

Debajit Dutta

(Business Solutions MVP)