0

I have an app with several users who log in on a regular basis to do Q/A on my data. Every single one of them can no longer log into the app. When they attempt to log in they are getting an expired token error. Here is my code:

client_creds = { orgName: "org", appName: "app" };

dataClient = new Apigee.Client( client_creds );

dataClient.login( username, password, function (error,response) {            
    if (error) {
        //error — could not log user in
        alert( error.message );
    } else {
        //success — user has been logged in
        token = dataClient.token;
        initializeUI();
    }
} );

I don't know if users are actually logging out or not. In any case why are users getting an expired token error? How can the token get refreshed on login?

MoreScratch
  • 2,933
  • 6
  • 34
  • 65
  • Are you storing the token indenfinitly? By default, it has a 3600s expiry. You may want to increase it? – brandonscript Nov 07 '16 at 17:47
  • If it's set by default to 3600s expiry then it stands to reason that there is a mechanism in place to refresh it. Otherwise, every 3600s users would need to create a new login or manually remove the token from local storage. Am I am missing something? – MoreScratch Nov 07 '16 at 17:57
  • There are no refresh tokens in Usergrid (unfortunately). You can increase the expiry, but yes, your assumption of the way to work around it is correct. – brandonscript Nov 07 '16 at 17:59
  • Many thanks. My solution is to set expiry to never - even though that is sub-optimal. – MoreScratch Nov 07 '16 at 23:17
  • I always end up doing the same, and I agree. Just make sure you invalidate the token on log out. – brandonscript Nov 07 '16 at 23:18

0 Answers0