What is the process for obtaining a new token in a Linnworks embedded application?

I decided to share my issue on this platform since the support from Linnworks is virtually non-existent.

My dilemma involves a private embedded app created within Linnworks that showcases orders in spreadsheet format. The app, constructed using Vue.js and axios for data retrieval from Linnworks APIs, works flawlessly except for one aspect - it only displays 100 orders at a time for efficiency purposes.

To address this limitation, I added a "load more orders" button that appends an additional 100 orders to the existing sheet. However, after a period of inactivity, this action triggers a "401 unauthorised error" due to token expiration.

Since the embedded app retains the token in the src attribute of the iframe during initialization, the expired token remains unchanged, leading to authorization issues.

<iframe src="https://example.com/sheet.html?token=9b11e8ff-4791-aca5-b58d-f6da84e996a6"></iframe>

Is there a method to obtain a refreshed token without reloading the entire app?

Answer №1

For tokens, the default Time To Live (TTL) is set to 30 minutes. To ensure your token/session stays active, simply use a basic method such as /api/Main/Ping to poll the API.

Answer №2

After receiving a response from Linnworks, I was able to resolve the issue:

Upon further investigation, it was discovered that the problem stemmed from the pinging of the AuthorizeByApplication call. To prevent the occurrence of a 401 Unauthorised "Token has expired. please re-verify the user" error, it is advised to make the AuthorizeByApplication call when the application is launched and save the response.

Once the session is established, there should be no need to call AuthorizeByApplication again. The token provided in this session has a TTL of 30 minutes. Using this token in subsequent calls will reset the TTL back to 30 minutes. Therefore, as mentioned in the response to your Stackoverflow query, periodically calling "api/Main/Ping" will refresh the 30-minute TTL with minimal impact on your application's performance.

To Prevent Applications From Using Expired Tokens:

  1. When launching the application, invoke AuthorizeByApplication and store the session response.
  2. Maintain the session by invoking "api/Main/Ping" with the stored session token to reset the TTL of the saved session.
  3. Utilize the original saved session token for all application calls.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Develop an exclusive "click-once" button for a webpage

Can anyone assist me in creating a "one-time clickable" button to launch my website? I've searched through numerous threads on Stack Overflow but haven't found a solution yet. ...

The scale line on the OpenLayers map displays the same metrics twice, even when the zoom level is different

When using the Openlayers Map scale line in Metric units, a specific zoom rate may be repeated twice during the zoom event, even though the actual zoom-in resolution varies on the map. In the provided link, you can observe that the zoom rates of 5km and ...

Clearing a Vue.js filter: a step-by-step guide

Below is my Vue Js code where I have successfully implemented a filter to API array elements. However, I am facing an issue when trying to set up a button that clears the filter upon clicking, restoring the page to its original state without any changes. ...

Use ag-Grid to customize your column headers with checkboxes, allowing you to easily select or deselect all items in that column. This feature is not limited to

In my experience with ag-grid, I often find myself needing to customize the first column header to include a checkbox. This allows me to easily perform actions such as selecting all or deselecting all rows in the grid. It's important to note that this ...

Issue encountered while initializing session_start() in PHP REACTJS AXIOS

https://i.sstatic.net/bSelX.pngWhen attempting to log in to my web application, I encountered an issue where the session is not opening after entering the correct email and password. Strangely, there is no PHPSESSID present in the console > application. ...

Increasing the ID of a select input using Jquery

Is there a way to modify the identification of my select field? This select option is dynamically created using PHP. The select input can be accessed through var indirectSelect Despite its simplicity, I am facing difficulty in changing it. I attempted th ...

Issue with alert not being triggered in browser when using HTML and JavaScript function

Just starting out with HTML and Javascript! I'm working on a simple program where users can input a card number, and the browser should indicate whether it is valid (between 13-16 digits) or not. The website looks great, but I'm not getting an ...

Solve the problem with SCSS at the component level in NextJS

I've decided to transition my regular React app to Next.js. In the past, I would simply import SCSS files using: import from '.componentName.scss' However, now I need to import them using: import style from 'componentName.module.scss ...

Setting a default value in the <v-select> component: A handy guide

After setting up a select component like this: <v-select px-4 class='select' v-model="form.accountType" :items="accountTypes" :label="$t('form.accountType')" :rules="[rules.required, rules.validAccountType]" ...

Creating a function in a JavaScript module that can be exported to the window namespace

One of the goals of modules is to protect variables and functions defined inside from being accessed outside the script. However, if you want to export a specific function for global use, there are ways to accomplish this. Merely assigning it to the window ...

Looking for a solution to troubleshoot issues with the updateServing function in JavaScript?

I am attempting to create a function that will calculate the portion sizes for the ingredients on my website. This function is located in the Recipe.js file and appears as follows: updateServings(type) { // Servings const newServings ...

Navigate to the second level array within the JSON data structure

As someone more inclined towards design rather than programming, any assistance is highly appreciated. The main goal of this project is to create a dropdown menu using the "name" field from the JSON data and display the corresponding "stock" information wh ...

The AJAX response consistently returns a 405 status code

I am experiencing an issue with an AJAX post request. $.ajax({ type: "POST", contentType: "application/json", url: "/rating/save", data: JSON.stringify(rating), dataType: "json", mimeType: "application/json" ...

Error encountered in Angular CLI: Attempting to access property 'value' of an undefined variable

I am encountering an issue while trying to retrieve the values of radio buttons and store them in a MySql database. The error message I receive is TypeError: Cannot read property 'value' of undefined. This project involves the use of Angular and ...

The function toDataURL() in Canvas is storing images in low resolution

I created a unique polygonal background generator using HTML5 canvas which can be found at the following link: http://codepen.io/rfalor/pen/LhinJ Here is the important part of the code: var canvas = document.getElementById("canvas"); var ctx = c ...

Different time parameter for setting a timeout in Javascript

I am struggling to create a slideshow with varying time intervals for each image. My knowledge of Javascript is limited, and I have been working on resolving this issue for quite some time. /* function ShowEffect(element){ new Effect.Appear(element, ...

Calculating the total number of days in each month within a specified date range using PHP in a dynamic way

Thank you for taking the time to help me with my issue. For instance, if a user selects a date range from 10 Dec 2016 to 20 April, how can I calculate the number of days for each month within that range? For example, Dec=22 Days, Jan=31 Days, Feb=28 Days, ...

Divs expanding below content in IE on a particular server

Currently, I am facing an issue with a JavaScript div that expands correctly over other content in most situations but goes under the content in one specific scenario. I am unsure about where to begin debugging this problem. To provide some context, the d ...

Issues arise with req.body being undefined when using node.js in conjunction with Express version 4.16.X and Body-Parser version

Recently, I began using node.js to construct a RESTFul API. Currently, my focus lies in inserting data through POST requests with JSON in the body. However, I encountered an issue where the req.body always returned as undefined. Upon investigating further ...

5% of the time, Ajax fails and the response is "error"

When utilizing jQuery for Ajax calls, I have encountered a situation where the call fails approximately 5% of the time. To troubleshoot and understand the issue better, I implement this code: $.ajax({ type:'POST', url:'somepage.php ...