[Vuejs]-How to get the refreshed token in a Linnworks embedded app?

3👍

Tokens have a default TTL of 30 minutes, just poll the API with a simple method like /api/Main/Ping to keep your token/session active

0👍

I got the following response from Linnworks, which fixed the problem:

After further investigation, this appears to be due to the the pinging of the AuthorizeByApplication call. To help reduce the risk of being returned a 401 Unauthorised “Token has expired. please re-verify the user”, it is recommended that when the application is opened, call AuthorizeByApplication and save the response.

Once the session has been created, AuthorizeByApplication should not have to be called again. The token returned in this session has a TTL of 30 minutes. If this token is used in a further call, the TTL of the token is reset back to 30 minutes. Therefore, as suggested in the response of your Stackoverflow question, briefly calling “api/Main/Ping” will reset the 30 minute TTL with little impact on your applications performance.

To Prevent Applications From Using Expired Tokens:

  1. Upon launching application, call AuthorizeByApplication and save session response.
  2. To keep the session from ending, call “api/Main/Ping” using the saved session token to reset the TTL of the saved session.
  3. For any calls made by the application, use the original saved session token.

Leave a comment