user logout issues when using REST AP

In my plugin, I'm using the SugarCRM function SUGAR.App.api.getOAuthToken()  for querying any data (get/post) on each ajax call of SugarCRM v10 REST API. Below is the piece of ajax request code

$.ajax({
beforeSend: function(request) {
request.setRequestHeader("OAuth-Token", SUGAR.App.api.getOAuthToken());
},
url: "rest/v10/Calls/",
data: {
"filter": [{
"id": callID
}]
},
type: "GET",
async: false,
success: function(data) {
contID = data.records[0].contact_id;
callStatus = data.records[0].status;
curCallID = data.records[0].id;
pType = data.records[0].parent_type;
pID = data.records[0].parent_id;
console.debug('[' + DateTime() + '] [DEBUG] sucessfull display phone numbers ...');

},
error: function(error) {
console.error(error);
var json = JSON.parse(error.responseText);
app1.alert.show('contact-ok', {
level: 'error',
messages: json.error_message,
autoClose: true
});
console.error('[' + DateTime() + '] [FATAL ERROR] display phone numbers ...');

}
});


We are facing one serious issue, some of the users automatically logged out from sugar while using the plugin. This is not happening with all plugin users. Don't know why this is happening. Is there the function SUGAR.App.api.getOAuthToken() is causing the problem.

Parents Reply Children