Tljh-reload stuck in infinite loop of Hub not ready: (HTTP status 502) InsecureRequestWarning: Unverified HTTPS request is being made to host while setting up azuread OAuthenticator

While setting up OAuthenticator for azuread by following this documentation: Azure AD Setup — OAuthenticator

sudo tljh-config reload is stuck in infinite loop of: Hub not ready: (HTTP status 502)
/opt/tljh/hub/lib/python3.10/site-packages/urllib3/connectionpool.py:1099: InsecureRequestWarning: Unverified HTTPS request is being made to host ‘127.0.0.1’. Adding certificate verification is strongly advised. See: Advanced Usage - urllib3 2.1.0 documentation
warnings.warn(

and
accessing the jupyterhub shows bad gateway exception in the browser. (mostly because relaod isn’t finished)

How to reproduce

  1. Create a JupyterHub
  2. Enable https for it
  3. In JupyterHub config:
auth:
    OAuthenticator:
        client_id: <client id created in azure ad using app registration>
        client_secret: <client secret created in azure ad using app registration>
    type: azuread
AzureAdOAuthenticator:
  tenant_id: <tenant id created in azure ad using app registration>
  scope: '[Read]'
  1. Run: ‘sudo tljh-config reload’

Can you show us your full configuration, and your JupyterHub logs?

Sure,
the tljh-config file looks like:

and the logs show this:
Dec 15 18:18:45 JupyterHub python3[2671]: File “/usr/lib/python3.6/importlib/init.py”, line 126, in import_module
Dec 15 18:18:45 JupyterHub python3[2671]: return _bootstrap._gcd_import(name[level:], package, level)
Dec 15 18:18:45 JupyterHub python3[2671]: File “”, line 994, in _gcd_import
Dec 15 18:18:45 JupyterHub python3[2671]: File “”, line 971, in _find_and_load
Dec 15 18:18:45 JupyterHub python3[2671]: File “”, line 955, in _find_and_load_unlocked
Dec 15 18:18:45 JupyterHub python3[2671]: File “”, line 665, in _load_unlocked
Dec 15 18:18:45 JupyterHub python3[2671]: File “”, line 678, in exec_module
Dec 15 18:18:45 JupyterHub python3[2671]: File “”, line 219, in _call_with_frames_removed
Dec 15 18:18:45 JupyterHub python3[2671]: File “/opt/tljh/hub/lib/python3.6/site-packages/oauthenticator/azuread.py”, line
Dec 15 18:18:45 JupyterHub python3[2671]: import jwt
Dec 15 18:18:45 JupyterHub python3[2671]: ModuleNotFoundError: No module named ‘jwt’
Dec 15 18:18:45 JupyterHub python3[2671]:
Dec 15 18:18:45 JupyterHub systemd[1]: jupyterhub.service: Main process exited, code=exited, status=1/FAILURE
Dec 15 18:18:45 JupyterHub systemd[1]: jupyterhub.service: Failed with result ‘exit-code’.
Dec 15 18:18:46 JupyterHub systemd[1]: jupyterhub.service: Service hold-off time over, scheduling restart.
Dec 15 18:18:46 JupyterHub systemd[1]: jupyterhub.service: Scheduled restart job, restart counter is at 4.
Dec 15 18:18:46 JupyterHub systemd[1]: Stopped jupyterhub.service.
Dec 15 18:18:46 JupyterHub systemd[1]: Started jupyterhub.service.
Dec 15 18:18:47 JupyterHub python3[2720]: /opt/tljh/hub/lib/python3.6/site-packages/jupyterhub/crypto.py:17: CryptographyDepreca
Dec 15 18:18:47 JupyterHub python3[2720]: import cryptography
Dec 15 18:18:47 JupyterHub python3[2720]: [E 2023-12-15 18:18:47.037 JupyterHub app:2991]
Dec 15 18:18:47 JupyterHub python3[2720]: Traceback (most recent call last):
Dec 15 18:18:47 JupyterHub python3[2720]: File “/opt/tljh/hub/lib/python3.6/site-packages/jupyterhub/app.py”, line 2988, i
Dec 15 18:18:47 JupyterHub python3[2720]: await self.initialize(argv)
Dec 15 18:18:47 JupyterHub python3[2720]: File “/opt/tljh/hub/lib/python3.6/site-packages/jupyterhub/app.py”, line 2478, i
Dec 15 18:18:47 JupyterHub python3[2720]: self.load_config_file(self.config_file)
Dec 15 18:18:47 JupyterHub python3[2720]: File “/opt/tljh/hub/lib/python3.6/site-packages/decorator.py”, line 232, in fun
Dec 15 18:18:47 JupyterHub python3[2720]: return caller(func, *(extras + args), **kw)
Dec 15 18:18:47 JupyterHub python3[2720]: File “/opt/tljh/hub/lib/python3.6/site-packages/traitlets/config/application.py”
Dec 15 18:18:47 JupyterHub python3[2720]: return method(app, *args, **kwargs)
Dec 15 18:18:47 JupyterHub python3[2720]: File “/opt/tljh/hub/lib/python3.6/site-packages/traitlets/config/application.py”
Dec 15 18:18:47 JupyterHub python3[2720]: self.update_config(new_config)
Dec 15 18:18:47 JupyterHub python3[2720]: File "/opt/tljh/hub/lib/python3.6/site-packages/traitlets/config/configurable.py
Dec 15 18:18:47 JupyterHub python3[2720]: self._load_config(config)
Dec 15 18:18:47 JupyterHub python3[2720]: File "/opt/tljh/hub/lib/python3.6/site-packages/traitlets/config/configurable.py
Dec 15 18:18:47 JupyterHub python3[2720]: setattr(self, name, deepcopy(config_value))
Dec 15 18:18:47 JupyterHub python3[2720]: File “/opt/tljh/hub/lib/python3.6/site-packages/traitlets/traitlets.py”, line 58
Dec 15 18:18:47 JupyterHub python3[2720]: self.set(obj, value)
Dec 15 18:18:47 JupyterHub python3[2720]: File “/opt/tljh/hub/lib/python3.6/site-packages/traitlets/traitlets.py”, line 55
Dec 15 18:18:47 JupyterHub python3[2720]: new_value = self._validate(obj, value)
Dec 15 18:18:47 JupyterHub python3[2720]: File “/opt/tljh/hub/lib/python3.6/site-packages/traitlets/traitlets.py”, line 59
Dec 15 18:18:47 JupyterHub python3[2720]: value = self.validate(obj, value)
Dec 15 18:18:47 JupyterHub python3[2720]: File “/opt/tljh/hub/lib/python3.6/site-packages/jupyterhub/traitlets.py”, line 1
Dec 15 18:18:47 JupyterHub python3[2720]: value = registry[key].load()
Dec 15 18:18:47 JupyterHub python3[2720]: File “/opt/tljh/hub/lib/python3.6/site-packages/entrypoints.py”, line 79, in loa
Dec 15 18:18:47 JupyterHub python3[2720]: mod = import_module(self.module_name)
Dec 15 18:18:47 JupyterHub python3[2720]: File “/usr/lib/python3.6/importlib/init.py”, line 126, in import_module
Dec 15 18:18:47 JupyterHub python3[2720]: return _bootstrap._gcd_import(name[level:], package, level)
Dec 15 18:18:47 JupyterHub python3[2720]: File “”, line 994, in _gcd_import
Dec 15 18:18:47 JupyterHub python3[2720]: File “”, line 971, in _find_and_load
Dec 15 18:18:47 JupyterHub python3[2720]: File “”, line 955, in _find_and_load_unlocked
Dec 15 18:18:47 JupyterHub python3[2720]: File “”, line 665, in _load_unlocked
Dec 15 18:18:47 JupyterHub python3[2720]: File “”, line 678, in exec_module
Dec 15 18:18:47 JupyterHub python3[2720]: File “”, line 219, in _call_with_frames_removed
Dec 15 18:18:47 JupyterHub python3[2720]: File “/opt/tljh/hub/lib/python3.6/site-packages/oauthenticator/azuread.py”, line
Dec 15 18:18:47 JupyterHub python3[2720]: import jwt
Dec 15 18:18:47 JupyterHub python3[2720]: ModuleNotFoundError: No module named ‘jwt’
Dec 15 18:18:47 JupyterHub python3[2720]:
Dec 15 18:18:47 JupyterHub systemd[1]: jupyterhub.service: Main process exited, code=exited, status=1/FAILURE
Dec 15 18:18:47 JupyterHub systemd[1]: jupyterhub.service: Failed with result ‘exit-code’.
Dec 15 18:18:47 JupyterHub systemd[1]: jupyterhub.service: Service hold-off time over, scheduling restart.
Dec 15 18:18:47 JupyterHub systemd[1]: jupyterhub.service: Scheduled restart job, restart counter is at 5.
Dec 15 18:18:47 JupyterHub systemd[1]: Stopped jupyterhub.service.
Dec 15 18:18:47 JupyterHub systemd[1]: jupyterhub.service: Start request repeated too quickly.
Dec 15 18:18:47 JupyterHub systemd[1]: jupyterhub.service: Failed with result ‘exit-code’.
Dec 15 18:18:47 JupyterHub systemd[1]: Failed to start jupyterhub.service.

looking at the ModuleNotFoundError: No module named ‘jwt’, installed the module but that didn’t help

What are the errors in the logs after you installed jwt? Also, is it possible for you to upgrade Python? Your logs contain some deprecation errors from crypography maybe due to Python 3.6!!

1 Like

When I run python --version I get Python 3.9.7.

When I install PyJWT it gets installed in ./.local/lib/python3.9/site-packages

Why does oauthenticator installation happens inside python3.6/site-packages? I tried installing the PyJWT package for python3.6 to satisfy the requirement but running python3.6 -m pip install PyJWT still installs the package in python3.9.7

Update: PyJWT module must be installed in the hub environment using sudo /opt/tljh/hub/bin/python3 -m pip install. I was installing this module in user environment which was not helping