Write token to file for user to access in his env

I have a custom authenticator which takes a token from the user’s auth_state. Now I write this token to his env with spawner.environment['REFRESH_TOKEN'] = self.exchange_token(auth_state['access_token'])

Is there a way to write the token to a file from within hub.extraConfig: or whats the best way for that?

The singleuser process is separate from the hub process, and in many cases they are on completely different servers.

If you want to write the value of an environment variable to a file you’ll need to do that in the singleuser server. For example, you could write a wrapper script that creates the file before calling jupyterhub-singleuser, use a lifecycle hook if you’re using Z2JH, write an extension, or something similar.

1 Like