Select to view content in your preferred language

How to change the expiration time of the token generated in application developed using Web App Builder

1032
2
02-05-2018 03:03 AM
MayurPatel
Emerging Contributor

Hi,
I have developed an app using Web App Builder developer Edition and I am trying to change the expiration time of the token in tokenUtils.js file as below 

         

 

 var oAuthInfo = esriNS.id.findOAuthInfo(portalUrl);

      if(!oAuthInfo){

        var oauthReturnUrl = window.location.protocol + "//" + window.location.host +

         require.toUrl("jimu") + "/oauth-callback.html";

        //OAuth will lose 'persist' query parameter if set expiration to two weeks exectly.

        oAuthInfo = new OAuthInfo({

          appId: appId,

          //expiration: 14 * 24 * 60 - 1,

          expiration: 2,

          portalUrl: portalUrl,

          authNamespace: '/',

          popup: true,

          popupCallbackUrl: oauthReturnUrl

        });

        esriNS.id.registerOAuthInfos([oAuthInfo]);

      }

 

 

 But while checking the response of generated token request in network tab, I am getting the token value and expiration time as below

{"token":"asdfghjk","expires":1518432766610,"ssl":false}

 Hence the token is not getting expired in 2 mins as desired.

0 Kudos
2 Replies
AlbertoCañivano1
Emerging Contributor

Mayur Patel‌ Good morning. Did you find a solution to this problem? I need to do something similar.
Thank you

0 Kudos
AlbertoCañivano1
Emerging Contributor

Mayur Patel‌ I just tested your solution and it works fine: my application asks to log back in and a new token is generated. Thanks!

0 Kudos