Force User to logout from the Agent App

SebastianB
Tera Guru

Hey hey,

have some experience with forced log out of the agent app?

I have some troubles with new features which are only shown when you logout and login again in the app, for example new push notification.

I do not want to write every user that he/she needs to logout from the app, so my question it is possible to logout all user only from the app, so that they need to login again.

I'm also happy if you have some other solution.

Thanks and regards

Sebastian

 

1 ACCEPTED SOLUTION

Fu
ServiceNow Employee
ServiceNow Employee

Hi Sebastian,

 

We don't a supported logout API for mobile but it is a feature on our roadmap, however, you can create a scripted action item that will remove the OAuth token for the current user. It's not a perfect solution but it's a workaround.

 

Ex:

(function WriteBackAction(input) {
    //Type appropriate comment here, and begin script below
	  var userId = gs.getUserID();
  
		var oAuthCredentials = new GlideRecord('oauth_credential');
		oAuthCredentials.addQuery('user', userId); 
		oAuthCredentials.query();
		while (oAuthCredentials.next()) {
			oAuthCredentials.deleteRecord();		
		}
	 gs.addInfoMessage("You have successfully logged out. Please pull to log back in.");
	
})(input);

View solution in original post

4 REPLIES 4

Fu
ServiceNow Employee
ServiceNow Employee

Hi Sebastian,

 

We don't a supported logout API for mobile but it is a feature on our roadmap, however, you can create a scripted action item that will remove the OAuth token for the current user. It's not a perfect solution but it's a workaround.

 

Ex:

(function WriteBackAction(input) {
    //Type appropriate comment here, and begin script below
	  var userId = gs.getUserID();
  
		var oAuthCredentials = new GlideRecord('oauth_credential');
		oAuthCredentials.addQuery('user', userId); 
		oAuthCredentials.query();
		while (oAuthCredentials.next()) {
			oAuthCredentials.deleteRecord();		
		}
	 gs.addInfoMessage("You have successfully logged out. Please pull to log back in.");
	
})(input);

David Ha
ServiceNow Employee
ServiceNow Employee

Hi Sebastian,

This feature is not something currently prioritized on the backlog.  You can help prioritize this feature by submitting to the idea portal: (category:mobile)

https://community.servicenow.com/community?id=ideas_list&sysparm_module_id=enhancement_requests

 

Best,

David

Rama Jha2
Giga Contributor

Did you happen to achieve this?

David Ha
ServiceNow Employee
ServiceNow Employee

Hi Rama,


Fu's answer is correct -- and that is currently a workaround we've heard of some customers using.

 

Best,

David