# GenericOAuthenticator won't read env vars in 1.0

**URL:** <https://discourse.jupyter.org/t/genericoauthenticator-wont-read-env-vars-in-1-0/984>\
**Category:** JupyterHub\
**Created:** [May 6, 2019, 6:11am UTC](https://discourse.jupyter.org/t/genericoauthenticator-wont-read-env-vars-in-1-0/984 "2019-05-06T06:11:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmatuskey](https://avatars.discourse-cdn.com/v4/letter/j/3ec8ea/32.png) [@jmatuskey](https://discourse.jupyter.org/u/jmatuskey)\
**Post date:** [May 6, 2019, 6:11am UTC](https://discourse.jupyter.org/t/genericoauthenticator-wont-read-env-vars-in-1-0/984/1 "2019-05-06T06:11:02Z")

</div>

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

```auto
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

```auto
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.

---

<div class="post-metadata">

**Author:** ![jmatuskey](https://avatars.discourse-cdn.com/v4/letter/j/3ec8ea/32.png) [@jmatuskey](https://discourse.jupyter.org/u/jmatuskey)\
**Post date:** [May 6, 2019, 9:17pm UTC](https://discourse.jupyter.org/t/genericoauthenticator-wont-read-env-vars-in-1-0/984/2 "2019-05-06T21:17:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![henchc](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/henchc/32/452_2.png) [@henchc](https://discourse.jupyter.org/u/henchc)\
**Post date:** [May 6, 2019, 10:37pm UTC](https://discourse.jupyter.org/t/genericoauthenticator-wont-read-env-vars-in-1-0/984/3 "2019-05-06T22:37:08Z")

</div>

Could this be related?

> <https://github.com/jupyterhub/oauthenticator/commit/650174e9801d1c5b046bbc5d7f70fd3120271527#diff-794d0b2ec706b4c1a73c19c990c0b7bd>

Not sure if you updated oauthenticator recently…

---

<div class="post-metadata">

**Author:** ![minrk](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/minrk/32/13_2.png) [@minrk](https://discourse.jupyter.org/u/minrk)\
**Post date:** [May 7, 2019, 8:15am UTC](https://discourse.jupyter.org/t/genericoauthenticator-wont-read-env-vars-in-1-0/984/4 "2019-05-07T08:15:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jmatuskey](https://avatars.discourse-cdn.com/v4/letter/j/3ec8ea/32.png) [@jmatuskey](https://discourse.jupyter.org/u/jmatuskey)\
**Post date:** [May 7, 2019, 3:10pm UTC](https://discourse.jupyter.org/t/genericoauthenticator-wont-read-env-vars-in-1-0/984/5 "2019-05-07T15:10:20Z")

</div>

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.
