{"err":{"stack":"invalid_token: Invalid token: access token has expired

Hello, quite a lot of errors are pouring due to an expired token, and requesting a new one. Is it possible

  1. How to increase the term of the token
  2. It is possible to somehow remove the appearance of errors if they do not affect the user experience
  3. Make sure that the token is requested in advance, for example)
    There are quite a lot of such errors per user per day.
    Thank you
{"err":{"stack":"invalid_token: Invalid token: access token has expired\n    at AuthenticateHandler.validateAccessToken (/var/www/peertube/versions/peertube-v6.2.1/node_modules/@node-oauth/oauth2-server/lib/handlers/authenticate-handler.js:223:13)\n    at AuthenticateHandler.handle (/var/www/peertube/versions/peertube-v6.2.1/node_modules/@node-oauth/oauth2-server/lib/handlers/authenticate-handler.js:71:32)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)","message":"Invalid token: access token has expired","statusCode":401,"status":401,"code":401,"name":"invalid_token"},"level":"info","message":"Cannot authenticate.","label":"angeltales.angellive.ru:443","timestamp":"2024-08-15T21:42:47.700Z"}
{"tags":["http"],"level":"info","message":"95.153.0.0 - - [15/Aug/2024:21:42:47 +0000] \"POST /api/v1/videos/6b8abccd-a6b8-434a-bb43-437a803fde64/views HTTP/1.0\" 401 265 \"https://angeltales.angellive.ru/w/p/1LE2HroLXqbhSLUKrhmD4D?playlistPosition=14\" \"Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Mobile Safari/537.36\"","label":"angeltales.angellive.ru:443","timestamp":"2024-08-15T21:42:47.708Z"}
{"err":{"stack":"invalid_token: Invalid token: access token has expired\n    at AuthenticateHandler.validateAccessToken (/var/www/peertube/versions/peertube-v6.2.1/node_modules/@node-oauth/oauth2-server/lib/handlers/authenticate-handler.js:223:13)\n    at AuthenticateHandler.handle (/var/www/peertube/versions/peertube-v6.2.1/node_modules/@node-oauth/oauth2-server/lib/handlers/authenticate-handler.js:71:32)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)","message":"Invalid token: access token has expired","statusCode":401,"status":401,"code":401,"name":"invalid_token"},"level":"info","message":"Cannot authenticate.","label":"angeltales.angellive.ru:443","timestamp":"2024-08-15T21:42:51.593Z"}
{"tags":["http"],"level":"info","message":"95.153.0.0 - - [15/Aug/2024:21:42:51 +0000] \"POST /api/v1/videos/6b8abccd-a6b8-434a-bb43-437a803fde64/views HTTP/1.0\" 401 265 \"https://angeltales.angellive.ru/w/p/1LE2HroLXqbhSLUKrhmD4D?playlistPosition=14\" \"Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Mobile Safari/537.36\"","label":"angeltales.angellive.ru:443","timestamp":"2024-08-15T21:42:51.594Z"}
{"err":{"stack":"invalid_token: Invalid token: access token has expired\n    at AuthenticateHandler.validateAccessToken (/var/www/peertube/versions/peertube-v6.2.1/node_modules/@node-oauth/oauth2-server/lib/handlers/authenticate-handler.js:223:13)\n    at AuthenticateHandler.handle (/var/www/peertube/versions/peertube-v6.2.1/node_modules/@node-oauth/oauth2-server/lib/handlers/authenticate-handler.js:71:32)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)","message":"Invalid token: access token has expired","statusCode":401,"status":401,"code":401,"name":"invalid_token"},"level":"info","message":"Cannot authenticate.","label":"angeltales.angellive.ru:443","timestamp":"2024-08-15T21:42:52.026Z"}
{"tags":["http"],"level":"info","message":"95.153.0.0 - - [15/Aug/2024:21:42:52 +0000] \"GET /api/v1/videos/9e1cb836-509e-45f7-a6e2-ef58e419d098/captions HTTP/1.0\" 401 184 \"https://angeltales.angellive.ru/w/p/1LE2HroLXqbhSLUKrhmD4D?playlistPosition=15\" \"Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Mobile Safari/537.36\"","label":"angeltales.angellive.ru:443","timestamp":"2024-08-15T21:42:52.027Z"}
{"err":{"stack":"invalid_token: Invalid token: access token has expired\n    at AuthenticateHandler.validateAccessToken (/var/www/peertube/versions/peertube-v6.2.1/node_modules/@node-oauth/oauth2-server/lib/handlers/authenticate-handler.js:223:13)\n    at AuthenticateHandler.handle (/var/www/peertube/versions/peertube-v6.2.1/node_modules/@node-oauth/oauth2-server/lib/handlers/authenticate-handler.js:71:32)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)","message":"Invalid token: access token has expired","statusCode":401,"status":401,"code":401,"name":"invalid_token"},"level":"info","message":"Cannot authenticate.","label":"angeltales.angellive.ru:443","timestamp":"2024-08-15T21:42:52.029Z"}
{"tags":["http"],"level":"info","message":"95.153.0.0 - - [15/Aug/2024:21:42:52 +0000] \"GET /api/v1/videos/9e1cb836-509e-45f7-a6e2-ef58e419d098/chapters HTTP/1.0\" 401 184 \"https://angeltales.angellive.ru/w/p/1LE2HroLXqbhSLUKrhmD4D?playlistPosition=15\" \"Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Mobile Safari/537.36\"","label":"angeltales.angellive.ru:443","timestamp":"2024-08-15T21:42:52.032Z"}
{"err":{"stack":"invalid_token: Invalid token: access token has expired\n    at AuthenticateHandler.validateAccessToken (/var/www/peertube/versions/peertube-v6.2.1/node_modules/@node-oauth/oauth2-server/lib/handlers/authenticate-handler.js:223:13)\n    at AuthenticateHandler.handle (/var/www/peertube/versions/peertube-v6.2.1/node_modules/@node-oauth/oauth2-server/lib/handlers/authenticate-handler.js:71:32)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)","message":"Invalid token: access token has expired","statusCode":401,"status":401,"code":401,"name":"invalid_token"},"level":"info","message":"Cannot authenticate.","label":"angeltales.angellive.ru:443","timestamp":"2024-08-15T21:42:52.059Z"}
{"tags":["http"],"level":"info","message":"95.153.0.0 - - [15/Aug/2024:21:42:52 +0000] \"GET /api/v1/videos/9e1cb836-509e-45f7-a6e2-ef58e419d098 HTTP/1.0\" 401 266 \"https://angeltales.angellive.ru/w/p/1LE2HroLXqbhSLUKrhmD4D?playlistPosition=15\" \"Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Mobile Safari/537.36\"","label":"angeltales.angellive.ru:443","timestamp":"2024-08-15T21:42:52.061Z"}
{"err":{"stack":"invalid_token: Invalid token: access token has expired\n    at AuthenticateHandler.validateAccessToken (/var/www/peertube/versions/peertube-v6.2.1/node_modules/@node-oauth/oauth2-server/lib/handlers/authenticate-handler.js:223:13)\n    at AuthenticateHandler.handle (/var/www/peertube/versions/peertube-v6.2.1/node_modules/@node-oauth/oauth2-server/lib/handlers/authenticate-handler.js:71:32)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)","message":"Invalid token: access token has expired","statusCode":401,"status":401,"code":401,"name":"invalid_token"},"level":"info","message":"Cannot authenticate.","label":"angeltales.angellive.ru:443","timestamp":"2024-08-15T21:42:52.101Z"}
{"tags":["http"],"level":"info","message":"95.153.0.0 - - [15/Aug/2024:21:42:52 +0000] \"GET /api/v1/videos/9e1cb836-509e-45f7-a6e2-ef58e419d098/storyboards HTTP/1.0\" 401 184 \"https://angeltales.angellive.ru/w/p/1LE2HroLXqbhSLUKrhmD4D?playlistPosition=15\" \"Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Mobile Safari/537.36\"","label":"angeltales.angellive.ru:443","timestamp":"2024-08-15T21:42:52.102Z"}
{"tags":["http"],"level":"info","message":"95.153.0.0 - - [15/Aug/2024:21:42:52 +0000] \"POST /api/v1/users/token HTTP/1.0\" 200 194 \"https://angeltales.angellive.ru/w/p/1LE2HroLXqbhSLUKrhmD4D?playlistPosition=15\" \"Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Mobile Safari/537.36\"","label":"angeltales.angellive.ru:443","timestamp":"2024-08-15T21:42:52.228Z"}

To avoid these expired token errors, try setting your token renewal to trigger before expiration. This can help maintain a seamless user experience without interruptions. You might also want to check if you can extend the token’s lifespan through configuration settings.

Thank you, great solution, the question remains how to do it or where to read? Also why is it not done by default?)

In general, this will not work, the client can log in in a month, a year, etc., in any case, the token will be updated when it is updated).