Skip to content


Authentication & Server Context

When interacting with a webKnossos server, you might need to specify your user token to authenticate yourself. You can copy your token from

Using the same methods, you can also specify the webknossos-server if you are not using the default instance.

There are the following four options to specify which server context to use:

  1. Specifying the context in code using the webknossos_context contextmanager in a with statement:

    with webknossos_context(token="my_webknossos_token"):
       # code that interacts with webknossos

    For more information about the with statement and contextmanagers, please see this tutorial.

  2. You may specify your settings as environment variables WK_TOKEN and WK_URL:

    WK_TOKEN="my_webknossos_token" python
  3. You can also specify those environment variables in a .env file in your working directory. Environment variables set in the command line take precedence.

    # content of .env
  4. If nothing else is specified and authentication is needed, you are asked interactively for a token, which is used for subsequent interactions in the same python run as well.

def webknossos_context( url: str = '', token: Union[str, NoneType] = None ) -> Iterator[NoneType]:
Back to top