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
  • That is correct; when you obtain a token you can only be logged in once per platform. You should add a custom platform into your instance of Sugar and then when you obtain the token use your custom platform.

    See the documentation at 

    support.sugarcrm.com/.../

  • Hi Jeff,

    thanks for the reply.

    There are two ways to obtain the access token
    1- rest/v10/oauth2/token via rest API by using the API platform and its responses are


      {

    "access_token": "xxxxxx-yyyy-zzzz-b1ef-aaaaadb"
    "expires_in": 3600
    "token_type": "bearer"
    "scope": null
    "refresh_token": "nnnnn-yyyy-zzzz-b1ef-aaaaadb"
    "refresh_expires_in": 1209599
    "download_token": "mmmmm-yyyy-zzzz-b1ef-aaaaadb"

    }
     and from here we can use access_token for Sugar rest v10 API(Get/Post)

    2- by using directly SUGAR.App.api.getOAuthToken() in javascript file, this function also provides the access_token and we can use access_token for Sugar rest v10 API(Get/Post).
     And in our plugin, most of the code has been done js side.

    Can you please suggest which option will be better? 

    And strange only one sugar client reported this issue, other sugar clients using the plugin without any issue.

Reply
  • Hi Jeff,

    thanks for the reply.

    There are two ways to obtain the access token
    1- rest/v10/oauth2/token via rest API by using the API platform and its responses are


      {

    "access_token": "xxxxxx-yyyy-zzzz-b1ef-aaaaadb"
    "expires_in": 3600
    "token_type": "bearer"
    "scope": null
    "refresh_token": "nnnnn-yyyy-zzzz-b1ef-aaaaadb"
    "refresh_expires_in": 1209599
    "download_token": "mmmmm-yyyy-zzzz-b1ef-aaaaadb"

    }
     and from here we can use access_token for Sugar rest v10 API(Get/Post)

    2- by using directly SUGAR.App.api.getOAuthToken() in javascript file, this function also provides the access_token and we can use access_token for Sugar rest v10 API(Get/Post).
     And in our plugin, most of the code has been done js side.

    Can you please suggest which option will be better? 

    And strange only one sugar client reported this issue, other sugar clients using the plugin without any issue.

Children
No Data