Skip to content

[FIX] Token request with Bearer returns error#4586

Merged
joragua merged 3 commits intomasterfrom
fix/token_request_error
May 29, 2025
Merged

[FIX] Token request with Bearer returns error#4586
joragua merged 3 commits intomasterfrom
fix/token_request_error

Conversation

@joragua
Copy link
Copy Markdown
Collaborator

@joragua joragua commented May 22, 2025

Related Issues

App: #4080

  • Add changelog files for the fixed issues in folder changelog/unreleased. More info here
  • Add feature to Release Notes in ReleaseNotesViewModel.kt creating a new ReleaseNote() with String resources (if required)

QA

Checks done: #4586 (comment)

Reports:

@joragua joragua self-assigned this May 22, 2025
@joragua joragua linked an issue May 22, 2025 that may be closed by this pull request
@joragua joragua marked this pull request as ready for review May 23, 2025 07:32
@joragua joragua requested a review from jesmrec May 23, 2025 07:38
@joragua joragua force-pushed the fix/token_request_error branch from 451f393 to f3974de Compare May 26, 2025 07:18
@joragua joragua requested a review from jesmrec May 26, 2025 07:34
@jesmrec
Copy link
Copy Markdown
Collaborator

jesmrec commented May 26, 2025

QA checks:

  • One account
  • Two accounts in different servers
  • Two accounts in the same server
  • Three accounts in the same server
  • Account switching
  • Working after token renewal

@jesmrec
Copy link
Copy Markdown
Collaborator

jesmrec commented May 27, 2025

(1) [FIXED]

I noticed the following effect in the current branch:

When the token expires and /konnect/v1/token is called to renew, the process is correct but the following request uses the expired token, causing un 401 and showing in the screen the snackbar dialog to re-authenticate. Just the following request, the following ones are OK and use the correct token. That means, user sees authentication is lost, bit it's not lost.

I realised that this 401 request is always a PROPFIND to /dav/spaces/... , that is expected but not sure...

After checking with master , it's not so reproducible as in the current branch. Also checked with two devices.

Maybe related with #4332

As required, this are the token request and response:

token.txt

and the request with the 401:

spaces.txt

As it is noticeable, the granted token in the first request is not the used token in the headers of the second one. Next requests are using the correct token.

@joragua
Copy link
Copy Markdown
Collaborator Author

joragua commented May 28, 2025

When the tokes expires, the next request after /konnect/v1/token includes an Authorization header with the expired token. In this case, the header must be replaced with the new token. Therefore, the header replacement should only be applied if the request path is not /konnect/v1/token. I will update the code and let's see if it is fixed 🤔

@joragua joragua force-pushed the fix/token_request_error branch from dd87004 to b5f7308 Compare May 28, 2025 12:26
@jesmrec
Copy link
Copy Markdown
Collaborator

jesmrec commented May 29, 2025

Last update works pretty fine! 💯 . No more fake authorization lost messages. Checked that the following request to the token one is already using the new token. So, (1) is fixed.

@jesmrec
Copy link
Copy Markdown
Collaborator

jesmrec commented May 29, 2025

Approved!

@joragua joragua force-pushed the fix/token_request_error branch from b5f7308 to 1c16639 Compare May 29, 2025 09:09
@joragua joragua merged commit e971cdd into master May 29, 2025
8 checks passed
@joragua joragua deleted the fix/token_request_error branch May 29, 2025 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Token request with Bearer returns error

3 participants