GenericOAuthenticator won't read env vars in 1.0

#1

Hi there, since 1.0 (worked in 0.9.6) I’m unable to get my jupyterhub running on kubernetes to even attempt to redirect to the OAUTH2_AUTHORIZE_URL I’ve set in my config.py like

os.environ["OAUTH2_AUTHORIZE_URL"]

I’ve tried to figure out what’s changed but I’m unable to pin it down, the behavior is that it keeps trying to redirect to /hub/oauth_login instead of my specified URL. Did something change with how env vars are set? Should there be an option in the config map to set the authorize URL?

Using GenericOAuthenticator, config below

hub:
  extraConfig:
    myConfig: |
      import os
      os.environ['OAUTH2_TOKEN_URL'] = "[redacted]"
      os.environ['OAUTH2_AUTHORIZE_URL'] = "[redacted]"

      from oauthenticator.generic import GenericOAuthenticator

      c.JupyterHub.authenticator_class = GenericOAuthenticator
      c.GenericOAuthenticator.userdata_url = "[redacted]"
      c.GenericOAuthenticator.token_url = "[redacted]"
      c.GenericOAuthenticator.username_key = "eppn"

      c.GenericOAuthenticator.login_service = "[redacted]"
      c.GenericOAuthenticator.client_id = "[redacted]"
      c.GenericOAuthenticator.client_secret = "[redacted]"
      c.GenericOAuthenticator.scope=["[redacted]"]

thanks a ton for any advice.

#2

Update - running locally with a debugger I believe I’ve discovered that the GenericOAuthenticator is being instantiated before the config code is run. Remember - this just changed in 1.0.0 and I’m having trouble tracking down the reason why

#3

Could this be related?

Not sure if you updated oauthenticator recently…

#4

Try using extraEnv instead of setting the env in Python in extraConfig. You are right that extraConfig is loaded too late for this to work.

#5

Thanks for your help - hub.extraConfig DID work, also I found that editing c.JupyterHub.authenticator_class.login_handler._OAUTH_AUTHORIZE_URL and the like worked as well.