Skip to content

[BUG] Refresh token is not updated after re-authentication with OIDC, causing repeated token expiration errors #4610

Open

Description

@restonica

Hello,

I’m using the Android OwnCloud app with a self-hosted OwnCloud server configured for OIDC authentication via Authelia. When the refresh token expires, the app correctly prompts for re-authentication, which succeeds. However, after this successful login, the app continues to send the old expired refresh token to the server, causing the server to reject it and the login to fail repeatedly.
The only workaround I found is to completely clear the app’s data on Android, which resets the tokens and allows a fresh authentication flow.
It appears that the app is not properly updating or replacing the stored refresh token after re-authentication, resulting in the use of stale tokens.
Steps to reproduce:

  1. Authenticate with OIDC via the app.
  2. Let the refresh token expire.
  3. Attempt to refresh the token → app prompts for login.
  4. Login succeeds, but app continues to send the expired refresh token.
  5. Server rejects the token and access fails.
    Expected behavior:
    After a successful re-authentication, the app should update the stored refresh token with the new one provided by the server and use it for subsequent token refreshes.
    Additional information:
    • Android OwnCloud app version: v4.5.1
    • OwnCloud server version: v10.15.2
    • OIDC provider: Authelia
    • Clearing app data fixes the issue temporarily

This issue causes a poor user experience and requires manual intervention to resolve.

Thank you for looking into this!

Activity

  1. jesmrec commented on Jun 23, 2025

    @jesmrec
    Member

    Hi @restonica! about the described problem, we have fixed the following issues recently:

    #4332
    #4080

    that will be available in 4.6.0 version, expected July. In advance, i will provide you a testing apk including the fixes, so that you can check if your problem is also fixed. Here it is:

    https://infinite.owncloud.com/s/hmOmoPzUtylHwax
    Pwd: LY|3y1[jr(}+

    If you have some time, give it a try and come back with your feedback ;)

    Thanks!!

  2. mwinters-stuff commented on Jul 20, 2025

    @mwinters-stuff

    I created an issue earlier, and saw this. Downloaded the app but still no authentication.

  3. jesmrec commented on Jul 21, 2025

    @jesmrec
    Member

    You mean, the app i shared with you? Within the current week, we'll release a new version with latest changes. If the problem persists, we can provide you a safe place in which you could share credentials of your server with us (if you wish), so that we could test with your server instance directly.

  4. jesmrec commented on Jul 22, 2025

    @jesmrec
    Member

    @restonica version 4.6.0 has been already released. Could you take a look? let us know whether the problem persists

  5. restonica commented on Jul 26, 2025

    @restonica
    Author

    Hi,
    Problem is still present with 4.6.0

  6. joragua commented on Aug 1, 2025

    @joragua
    Member

    Hi @restonica! We have just released a new version (4.6.1), now available on the Play Store! This release includes a potential bugfix for re-login when credentials expire. Could you check it? Let us know if the problem persists 🤔

  7. DeepDiver1975 commented on Jul 2, 2026

    @DeepDiver1975
    Contributor

    Likely already fixed in 4.7.0 (current release: 4.8.2) — needs a retest.

    Verified against current master, the token-refresh persistence path looks correct, so the symptom is not a stale-token storage bug:

    • Silent refresh persists the rotated refresh token: AccountAuthenticator.java handleSuccessfulRefreshToken() writes KEY_OAUTH2_REFRESH_TOKEN on every successful refresh (falls back to the old one only if the IdP returns none).
    • Re-auth persists the new token too: OCLocalAuthenticationDataSource.addOAuthAccount() overwrites KEY_OAUTH2_REFRESH_TOKEN for the updated account.

    The Authelia-specific failure looks like the token request, not token storage. #4575 (same setup: OIDC + Authelia, re-auth fails right after a successful login) was fixed in 4.7.0 by #4671 — the token request now sends client_secret_post / the authorization header only when the IdP's token_endpoint_auth_methods_supported calls for it. Authelia commonly uses client_secret_post, which older builds handled wrong.

    Timeline note: your last confirmed test was 4.6.0. 4.6.1 (#4654) only changed the re-login startActivity flow — not the Authelia auth-method fix, which landed later in 4.7.0.

    Please retest on the latest Play Store build (4.8.2) and report back. If it still fails there, capture the token-request/response (client auth method + error) so we can pin the exact cause.

    🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions