How to pass access_token from Auth0 to the user's pod?


I would like to passe some information to the user’s pod such like the auth_token. I guess it is possible to pass some information with c.KubeSpawner.pre_spawn_hook (and environment variable) but I can’t access to the token. How can I pass that information, please ?


I have found the solution. Here is what I made :

  extraConfig: |
      from oauthenticator.auth0 import Auth0OAuthenticator
      from tornado import gen
      class CustomAuth0OAuthenticator(Auth0OAuthenticator):
        async def pre_spawn_start(self, user, spawner):
          spawner.log.debug('BEGIN pre_spawn_start')
          auth_state = await user.get_auth_state()
          spawner.environment['ACCESS_TOKEN'] = auth_state['access_token']
          spawner.environment['ID_TOKEN'] = auth_state['id_token']
          spawner.log.debug('END pre_spawn_start')
1 Like