You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Getting logged out after access token expires while refresh token is still valid. #1595
Getting logged out after access token expires while refresh token is still valid. Even if you have activity
Steps to reproduce
Go to opencloud url and authenticate on Authentik IDP
After successful authentication, use opencloud / wait for 5 minutes and get logged out.
Need to authenticate again
Expected behavior
My access token is valid for 5 minutes but my refresh token is valid for 30 days. If the access token fails the introspect, I expect the refresh token to be used to retrieve a new access token but instead a logout is requested.
Actual behavior
After 5 minutes, I get redirected back to my OIDC IDP to authenticate again.
Setup
Running the docker compose with Authentik as OIDC IDP.
Details
Request that Opencloud makes after 5 minutes (i've masked the URL's):
This is likely unrelated to the refresh_token. AFAIK the web client doesn't even request the offline_access scope. So depending on the concrete IDP it might not even get a refresh_token.
Not too sure, as there isn't a http401 error in the logs. There isn't anything in the logs really, just a http301 redirect to the IDP logout endpoint exactly after the access token expires.
This also affects the default IDP (not only external IDP):
When using WEB_OIDC_SCOPE="openid profile email offline_access", a refresh token is issued and saved in the LocalStorage. However 5 minutes after closing the browser (IDP session expires) the user is required to log in again.
I'd expect OpenCloud to use its refresh token to acquire a new access token. Re-login should only be necessary after 30 days of inactivity.
When opening OpenCloud after 5 minutes, two requests fail with Status 401:
/api/v0/settings/roles-list
/graph/v1.0/me?%24expand=memberOf
Then immediately the user is being redirected to the signin page. Maybe those requests are executed before the access token was refreshed... which would make this some kind of race condition?
FYI: I am using authentik IDP: I set my access token validity in authentik to 1 minute and my scope to: openid profile email and offline_access and then set WEB_OIDC_SCOPE=openid profile email offline_access and PROXY_OIDC_ACCESS_TOKEN_VERIFY_METHOD=jwt (jwt or none depending on your setup will work with either) in the env, after that I made sure connect-src and script-src was set correctly in csp.yaml -- after that the 5 minute logout issue dissapeared -- the key seems to be the 1 minute access token validity being below the 5 minutes, using offline_access, and correcting csp.yaml
But that only makes a difference when using an external IDP, right? My problem is when using the internal IDP, and this is a usecase which should by any means work out of the box.
The default accessTokenLifespan in keycloak is set to 300 (5 minutes) in the default install, if there is any timing issues happening it's probably gonna log you out like what I was getting in Authentik -- set the accessTokenLifespan = 120 which is 2 minutes, restart and see if it fixes it -- my best guess is the issue might be with the cache/token expiry aligning and other checks firing at the five minute mark, with the access token set to two minutes or one minute like I did, the issue should dissapear or happen very very rarely if at all, hopefully it gets fully fixed in an update, in my case I also had to set offline_access which should be set by default in the opencloud keycloak install.
I'm not sure we are talking about the same thing. When OpenCloud is open (browser is open) the token gets refresh via timer, also using the refresh_token (when offline_access is enabled).
My problem is when reopening OpenCloud after some time: access_token seems to be used even if the client knows it has expired and the refresh_token is not used even if it's there and valid:
[authService:initializeContext] - updating context with saved access_token index.html-CGFTrQAi.mjs:37:51950
Because the XHR GET and/or POST requests fail with 401 (because the expired token is used), the client then decides to redirect to Lico and OIDC login (or silent-refresh) page instead of using the refresh_token in the LocalStorage to refresh the token. Lico on the other hand has no session anymore (which is fine), so the user needs to log in again.
@c-hicks Does this work with Keycloak? E.g. log in, close the OpenCloud page, wait >5 minutes, delete all Keycloak cookies (so silent refresh will fail) and then open OpenCloud again.
Hard to say without a reproducible instance to be honest. It works just fine for me with Lico.
The steps analyzed in #1595 (comment) are on point, there shouldn't be a 401 in the first place. Once that happens, the web client rightfully redirects to the login.
In the console you see requests to /graph/v1.0/me?$expand=memberof and /api/v0/settings/roles-list. For both requests, the expiredaccess_token is used despite knowing better (expires_at!).
The refresh_token is not used at all, but the user is redirected to the login (or redirected through Keycloak's silent authentication when the cookies for keycloak.demo.opencloud.eu are not deleted).
FYI: I am using authentik IDP: I set my access token validity in authentik to 1 minute and my scope to: openid profile email and offline_access and then set WEB_OIDC_SCOPE=openid profile email offline_access and PROXY_OIDC_ACCESS_TOKEN_VERIFY_METHOD=jwt (jwt or none depending on your setup will work with either) in the env, after that I made sure connect-src and script-src was set correctly in csp.yaml -- after that the 5 minute logout issue dissapeared -- the key seems to be the 1 minute access token validity being below the 5 minutes, using offline_access, and correcting csp.yaml
I can confirm that this worked for me too, except I didn't even need to set the JWT verification method. Just adding offline_access to the OIDC scope seems to have helped.
I think this issue has been fixed with the recent changes in opencloud-eu/web#2230 (available with OpenCloud v6). Having set the offline_access scope will now correctly use the refresh token to obtain a new access token, ensuring the user stays logged in, e.g. after closing the browser.
There is still some optimization left to do (avoid the requests to /graph/v1.0/me and /api/v0/settings/roles-list when the token is expired), but that doesn't hurt for now.
Activity
rhafer commentedon Oct 2, 2025
I think you're suffering from #1493
This is likely unrelated to the
refresh_token. AFAIK the web client doesn't even request theoffline_accessscope. So depending on the concrete IDP it might not even get arefresh_token.jeffreyvangorkum commentedon Oct 2, 2025
Not too sure, as there isn't a http401 error in the logs. There isn't anything in the logs really, just a http301 redirect to the IDP logout endpoint exactly after the access token expires.
nicokaiser commentedon Dec 3, 2025
This also affects the default IDP (not only external IDP):
When using
WEB_OIDC_SCOPE="openid profile email offline_access", a refresh token is issued and saved in the LocalStorage. However 5 minutes after closing the browser (IDP session expires) the user is required to log in again.I'd expect OpenCloud to use its refresh token to acquire a new access token. Re-login should only be necessary after 30 days of inactivity.
nicokaiser commentedon Dec 4, 2025
When opening OpenCloud after 5 minutes, two requests fail with Status 401:
Then immediately the user is being redirected to the signin page. Maybe those requests are executed before the access token was refreshed... which would make this some kind of race condition?
c-hicks commentedon Dec 8, 2025
FYI: I am using authentik IDP: I set my access token validity in authentik to 1 minute and my scope to: openid profile email and offline_access and then set WEB_OIDC_SCOPE=openid profile email offline_access and PROXY_OIDC_ACCESS_TOKEN_VERIFY_METHOD=jwt (jwt or none depending on your setup will work with either) in the env, after that I made sure connect-src and script-src was set correctly in csp.yaml -- after that the 5 minute logout issue dissapeared -- the key seems to be the 1 minute access token validity being below the 5 minutes, using offline_access, and correcting csp.yaml
nicokaiser commentedon Dec 8, 2025
But that only makes a difference when using an external IDP, right? My problem is when using the internal IDP, and this is a usecase which should by any means work out of the box.
c-hicks commentedon Dec 8, 2025
The default accessTokenLifespan in keycloak is set to 300 (5 minutes) in the default install, if there is any timing issues happening it's probably gonna log you out like what I was getting in Authentik -- set the accessTokenLifespan = 120 which is 2 minutes, restart and see if it fixes it -- my best guess is the issue might be with the cache/token expiry aligning and other checks firing at the five minute mark, with the access token set to two minutes or one minute like I did, the issue should dissapear or happen very very rarely if at all, hopefully it gets fully fixed in an update, in my case I also had to set offline_access which should be set by default in the opencloud keycloak install.
nicokaiser commentedon Dec 9, 2025
I'm not sure we are talking about the same thing. When OpenCloud is open (browser is open) the token gets refresh via timer, also using the refresh_token (when offline_access is enabled).
My problem is when reopening OpenCloud after some time: access_token seems to be used even if the client knows it has expired and the refresh_token is not used even if it's there and valid:
Because the XHR GET and/or POST requests fail with 401 (because the expired token is used), the client then decides to redirect to Lico and OIDC login (or silent-refresh) page instead of using the refresh_token in the LocalStorage to refresh the token. Lico on the other hand has no session anymore (which is fine), so the user needs to log in again.
@c-hicks Does this work with Keycloak? E.g. log in, close the OpenCloud page, wait >5 minutes, delete all Keycloak cookies (so silent refresh will fail) and then open OpenCloud again.
micbar commentedon Dec 15, 2025
@kulmann @JammingBen Any hints from the web client POV?
JammingBen commentedon Dec 16, 2025
Hard to say without a reproducible instance to be honest. It works just fine for me with Lico.
The steps analyzed in #1595 (comment) are on point, there shouldn't be a
401in the first place. Once that happens, the web client rightfully redirects to the login.nicokaiser commentedon Dec 16, 2025
demo.opencloud.eu is a reproducible instance:
access_token, arefresh_tokenandexpires_at(in 5 minutes) is written to the Local StorageIn the console you see requests to
/graph/v1.0/me?$expand=memberofand/api/v0/settings/roles-list. For both requests, the expiredaccess_tokenis used despite knowing better (expires_at!).The
refresh_tokenis not used at all, but the user is redirected to the login (or redirected through Keycloak's silent authentication when the cookies for keycloak.demo.opencloud.eu are not deleted).madduck commentedon Feb 9, 2026
I can confirm that this worked for me too, except I didn't even need to set the JWT verification method. Just adding
offline_accessto the OIDC scope seems to have helped.JammingBen commentedon Apr 10, 2026
I think this issue has been fixed with the recent changes in opencloud-eu/web#2230 (available with OpenCloud v6). Having set the
offline_accessscope will now correctly use the refresh token to obtain a new access token, ensuring the user stays logged in, e.g. after closing the browser.There is still some optimization left to do (avoid the requests to
/graph/v1.0/meand/api/v0/settings/roles-listwhen the token is expired), but that doesn't hurt for now.rhafer commentedon Apr 13, 2026
Closing as fixed as per last comment.