I can’t fully infer your issue here, but you aren’t setting OAUTH2_USERDATA_URL in the env vars as a start.
From generic.py (generic OAuthenticator)
if self.userdata_url:
url = url_concat(self.userdata_url, self.userdata_params)
else:
raise ValueError("Please set the OAUTH2_USERDATA_URL environment variable")
Actually, I think I just ended up setting everything in hub.extraEnv because that’s where the generic authenticator actually gets its values instead of from the config. This was my working structure:
hub:
extraEnv:
#Endpoints
OAUTH2_AUTHORIZE_URL: 'https://host/oauth2/token'
OAUTH2_TOKEN_URL: 'https://host/oauth2/token'
# Jupyterhub callback (default: https://<host>/hub/oauth_callback)
OAUTH_CALLBACK_URL: 'https://hub.host/hub/oauth_callback'
# User information is used to name server created by kubespawner.
OAUTH2_USERDATA_URL: 'https://host/jupyter_userdata'
OAUTH2_USERNAME_KEY: 'username_key'
OAUTH2_USERDATA_METHOD: 'GET'
# General settings
OAUTH2_BASIC_AUTH: 'false'
OAUTH2_TLS_VERIFY : 'true'
Two things to make sure of:
If you are using your own custom oauth, are you making sure that you implemented a listener/endpoint/handler at oauth_userdata_url?
I won’t paste too much code here but in generic.py (the generic OAuthenticator):
if not resp_json.get(self.username_key):
self.log.error("OAuth user contains no key %s: %s", self.username_key, resp_json)
return
You need to be certain that whatever provider you are using for your auth is returning a json dict that includes a key value pair where at least one key == ‘username_key’.
This is also what my config looks like, I added almost everything in the env vars and auth does work. If you gave me a little more detail perhaps I could help further.
Sadly that did not fix my issues. I double checked all the values set in my config and it seems (atleast I think thats whats happening) that the GenericAuthenticator does not pick up my Authorize URL.
As you proposed I now set all the variables inside the extra env, however looking at the logs it seems like my request gets send via:
Jun 24 08:24:51 python3[14735]: [I 2019-06-24 08:24:51.784 JupyterHub log:158] 302 GET /hub/oauth_login?next= -> ?response_type=code&redirect_uri=<URI>&client_id=<id>&state=[secret]
Shouldnt there be the proper authorize url after the next=? After that it redirects with the above parameters to itself again and again, being stuck in said loop.
I have to admit, for a demo yesterday we now just hardcoded the Authorize URL inside the python sitepackage of the oauthenticator. This is of course not a permanent solution.
But this shows me that the Authorize URL not being read is the only problem we have. The oauth is working find as soon as I hardcode it inside generic.py.
Regarding the OAuth Provider:
Im breaking out from Wordpress into JupyterHub via OAuth. Which means, I authenticate the signed in WP User in JupyterHub and use WP as the OAuth provider!