Skip to content

File Upload fails if authentication token is refreshed while on submission form (401Unauthorized error) #3979

@MoeBen23

Description

@MoeBen23

Description

Hi,

Some of our users have reported encountering errors when uploading files after a certain period of time. Specifically, the DSpace client displays an “Error Loading File” message once the JWT token is renewed by the front-end client.

This issue arises when a user’s submission process exceeds 30 minutes. The front-end client renews the token 2 minutes before session timeout; however, it does not use the new token if the user attempts to upload files after the renewal.

We are currently using DSpace 7.6.2. Could you provide any insights or recommendations on resolving this issue?

Thanks.

Steps to Reproduce

Steps to reproduce the behavior:

  1. Log in to DSpace using local authentication.
  2. Start a new submission.
  3. Upload files periodically (e.g., every few minutes). Initially, all uploads succeed.
  4. The DSpace client automatically renews the JWT token via a server call to the /login endpoint.
  5. After the token renewal, any subsequent file upload attempts fail with a 401 Unauthorized error.

Expected behavior

The JWT token timeout is set to 30 minutes. By default, the client renews the token 2 minutes before expiration. Once the new token is received, it should be used for all subsequent file uploads without failure.

Observed Issue

Currently, file uploads continue to use the expired token instead of the newly issued one.
On failed upload requests, the Bearer token in the request header differs from the token stored in the cookie, indicating a mismatch.

Screenshots:

In the screenshot below, I monitored network traffic using Google Chrome Developer Tools

Image1: Three uploads were done successfully

Image

Image 2: DSpace renews the token. This happens 2 min before it expires.

Image

Image 3: All uploads attempts fail after the token renewal. I attempted to upload two files.

Image

Image

Image 4: The failed upload request contains a different token in the header compared to the one in the cookie. It uses the old one in the header, and the new one in the cookie.

Image

Metadata

Metadata

Assignees

Type

Projects

Status

🏗 In Progress

Status

🏗 In Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions