ValueError: oauth_client_id cannot be empty when using HubOAuth with flask service

Hello everyone.

I currently have an external flask service which interacts with Jhub. I am using Oauth with flask (Flask-oidc) as well as Jhub. I realized I can remove flask OIDC altogether if I use Jhub to authenticate user. So I followed https://github.com/jupyterhub/jupyterhub/blob/22f86ad76c437d37bc26c28d9fecfa5457ef5974/examples/service-whoami-flask/whoami-oauth.py this example. I added this code to my existing flask app which is registered in config.yaml. I am setting JUPYTERHUB_SERVICE_PREFIX and JUPYTERHUB_API_TOKEN in my app.

But I am getting ValueError: oauth_client_id cannot be empty when tried using HubOAuth with flask service.

Is there something I am missing? I looked for similar errors on Stack Overflow or on older Github discussions, it seems it should be resolved in new version of Z2JH.

Any guidance on this will be really appreciated. Thanks.

I fixed this by setting Client ID ENV var. Now I get different error saying client_id invalid. Which is kind of misleading cause I have confirmed client ID at all the places. Will try to resolve that issue.

@n3o-Bhushan I have a flask app running external from the hub. I’d like to register the service and use the hub as oauth for the external service. Is your code on github? I followed the example above as well and was unable to get it working.

@jgerardsimcock I did not go ahead with it in the end. I have a flask service which authenticates differently and then talks with Jhub (which maintains its own authentication). I do have an item on my backlog for this though. I will let you know when I get back to this.

Ok. Thank you @n3o-Bhushan Good to know. I was using flask-dance lib to auth to my flask app but I wanted to save a step and use the hub auth and also have the application accessible from the hub ui as a button. I’ve currently removed the auth and simply added the service to my jupyterhub_config.py. I’ll play around with the auth code in the examples and see if I can get it to work. I too will let you know if I get it up and running.

1 Like