Trigger refresh user endpoint

Hi Everyone, I am working on an extension which requires oauth token. Currently I am using auth_state endpoint to get token from jupyterhub but I want to get the new token after refresh and I want to trigger it manually from the extension. I know there is a way to get new token by setting refresh_auth_age(something like that) which triggers refresh user in some time interval but I have some requirement which requires triggering it manually.

What kind of extension are you working on? A JupyterLab extension? A JupyterHub extension/service?

My extension and hub both use same oauth service so I was using auth state to get token from hub

There is currently not an API to directly trigger refresh_user.

User auth is refreshed at these three events:

  • login
  • when the user makes an authenticated request after auth_refresh_age seconds
  • prior to spawn, if refresh_pre_spawn is True

So technically, you can trigger refresh_user by launching their server.

It is a reasonable feature request to allow triggering refresh_user directly for the purposes of refreshing tokens, etc.

I have a use case where I log into my server and launch JupyterLab using DockerSpawner. While working in JupyterLab, I frequently need a refreshed token. To manage this, I use the auth state endpoint to obtain the token whenever required.

Sometimes, users create resources and automatically receive access permissions for those resources. However, the current token may not immediately reflect these new permissions. Therefore, I need a refreshed token to ensure proper access. To address this, I have added endpoints to the JupyterHub source code that allow me to manually trigger a refresh of the auth state.