How to skip OAuth login when running E2E tests with an admin token in Jupyterhub 4.0


I want to know if is there a way to skip OAuth login when running E2E tests(puppeteer program) with an admin token in Jupyterhub 4.0.

Previously we had these E2E tests working before an upgrade, recently we have had an upgrade of Jupyterhub from version 1.4 to 4.0, and these E2E tests are no longer working.

We find in the old jupyterhub version that https://<hub_url>/user/<user>/tree?token=<admin_token> in the incognito browser will all show the files. However, in the new version, we could only see empty pages like below, and click on any button will lead us to the Github OAuth page in the first reply.

the <admin_token> above mentioned at the end of the url was generated from an admin via the hub_url/hub/token page. Also the token works well with both hub rest api(hub_url/hub/api) and notebook rest api(hub_url/user//api).

Is this change expected from 1.4 to 4.0, is there some way we could fix this behavior? and in case you need more information, please let me know.

1 Like

new user is only allowed to give one media in a post, so I put the second here.

1 Like

That was removed a long time ago, in v2!

There are also several other security related improvements related to cookies and tokens in subsequent PRs.

How are you running your E2E tests? We use Playwright to test JupyterHub:


thanks for the fast reply, we run E2E tests not partiicular for the jupyterhub, but mainly on a notebook extension we add to the server. We are using the puppeteer framework and above mentioned trick to login to the server page, then click through all the UI buttons provided by the extnesion. Eventually verify the results.

Currently, after upgrading the jupyterhub, the E2E tests stuck at the very beginning,
do you see if there is a way to fix this authentication/authorization process?

I’ve just realised this is a known bug. It’s been fixed in the main branch

This is being backported to JupyterHub 4:

and the way to work around the bug in the meantime is to set JUPYTERHUB_SINGLEUSER_EXTENSION=0 to use the older singleuser server integration.

c.Spawner.environment = {"JUPYTERHUB_SINGLEUSER_EXTENSION": "0"}
1 Like

thank you both for the reply, I’ve tried to install the jupyterhub from the main branch(version 5), and it works, but when I try to reinstall the jupyterhub 4(since backported completed ), I see a Database related error. And the jupyterhub is installed in a k8s environment

FAILED: Can't locate revision identified by '3c2384c5aae1'
[E 2024-02-07 15:30:05.654 JupyterHub app:3382]
    Traceback (most recent call last):
      File "/opt/conda/lib/python3.9/site-packages/jupyterhub/", line 3379, in launch_instance_async
        await self.initialize(argv)
      File "/opt/conda/lib/python3.9/site-packages/jupyterhub/", line 2901, in initialize
      File "/opt/conda/lib/python3.9/site-packages/jupyterhub/", line 1835, in init_db
        dbutil.upgrade_if_needed(self.db_url, log=self.log)
      File "/opt/conda/lib/python3.9/site-packages/jupyterhub/", line 135, in upgrade_if_needed
      File "/opt/conda/lib/python3.9/site-packages/jupyterhub/", line 84, in upgrade
        check_call(['alembic', '-c', alembic_ini, 'upgrade', revision])
      File "/opt/conda/lib/python3.9/", line 373, in check_call
        raise CalledProcessError(retcode, cmd)
    subprocess.CalledProcessError: Command '['alembic', '-c', '/tmp/tmpsxonbkwg/alembic.ini', 'upgrade', 'head']' returned non-zero exit status 255.

I also see the alembic version in the database, is there a graceful way to fix this without deleting the entire database?

hub=# select * from alembic_version
hub-# ;
(1 row)

I also tried to fix the token in url issue via the environment variable way.
c.Spawner.environment = {"JUPYTERHUB_SINGLEUSER_EXTENSION": "0"}
however, this doesn’t work yet on my side, maybe I missed something.

Sorry for not highlighting this, it’s why I mentioned a test system! If I remember correctly there should be a backup of the SQLite database file in the same K8s volume.

Thanks for the fast reply, I am using a test system so there’s not much to worry, just a bit curious about how to fix it elegantly. I will try to have a look at this SQLite database, if not I will create a new one. : )

Another issue I noticed that after installing the jupyterhub via command

pip install

the admin page becomes empty like screenshot below, is this expected? I fixed the previously mentioned database issue, all data are persisted in the database and deployed version 4.0.2. the Admin’s page seems to work again. Is there something wrong with this Admin page in the new version?

Screenshot 2024-02-07 at 21.18.00
and the admin-react.js seems missing

I see, I think I figured it out, I need to build the package to get data files ready, inspired by the Dockerfile

Can you try

pip install git+

so the git metadata is included?