Auth_state_hook not running

def auth_state_hook(spawner, auth_state):
    print("_______________________________________")
    print(auth_state)

c.KubeSpawner.auth_state_hook = auth_state_hook

I am using this piece of code in jupyter_config.py file to set some environment variable but in the hub pod logs there is nothing being logged. i am using KubeSpawner and enable_auth_state is also enabled. What could be the possible problem? and also is there any other way to pass variable auth_state data into single user’s env variables? Any help is much appreciated !

Use as follows and normally, if everything is well configured, you will see the line in the JupyterHub logs

def auth_state_hook(spawner, auth_state):
    spawner.log.info("Auth state: %s", auth_state)

c.KubeSpawner.auth_state_hook = auth_state_hook

[/quote]

ohk thanks.
but i had another problem. The auth_state_hook runs only at spawn time as mentioned here.
I want to update the single user’s env variables everytime the user logs in/ authenticate.

If the singleuser server is already running when the user logs in it’s not possible to update the environment. You’ll need to implement some other way for your singleuser server to dynamically fetch the updated variables.