Configuration Details

While it is possible to enter the server URL and access credentials (see Access Token Management) each time a new request object is created,

from viresclient import SwarmRequest

# both URL and access token passed as request object's parameters
request = SwarmRequest(

it is more convenient to omit them from the code and store them in a private configuration file. This configuration can be done using the viresclient.set_token() convenience function, the underlying viresclient.ClientConfig() module, or the command line interface (CLI) - see below. These will all set the configuration options in a file which is by default located at ~/.viresclient.ini which can be edited directly, containing for example:

token = r-8-mlkP_RBx4mDv0di5Bzt3UZ52NGg-

url =

When creating the configuration file manually make sure the file is readable by its owner only:

$ chmod 0600 ~/.viresclient.ini
$ ls -l ~/.viresclient.ini
-rw-------  1 owner owner  361 May 12 09:12 /home/owner/.viresclient.ini

When the configuration file is present, then the url and token options can be omitted from requests:

# access token read from configuration
request = SwarmRequest(url="")

# both default URL and access token read from configuration
request = SwarmRequest()

The following sections describe how to set the configuration.

Configuration via CLI

The viresclient shell command can be used to set the server access configuration:

$ viresclient set_token
Enter access token: r-8-mlkP_RBx4mDv0di5Bzt3UZ52NGg-

$ viresclient set_default_server

See also: Command Line Interface (CLI)

Configuration via Python

Use the following code to store the token in the viresclient configuration:

from viresclient import ClientConfig

cc = ClientConfig()
cc.set_site_config("", token="r-8-mlkP_RBx4mDv0di5Bzt3UZ52NGg-")
cc.default_url = ""

Alternatively, use the convenience function:

from viresclient import set_token
# (you will now be prompted to enter the token)

which calls the same code as above, but makes sure the token remains hidden so that it can’t accidentally be shared.

For developers & DISC users

The accounts for the staging server (, and DISC server ( are separate. Tokens can be similarly generated on these and stored in the same configuration file alongside the others:

$ viresclient set_token
Enter access token: r-8-mlkP_RBx4mDv0di5Bzt3UZ52NGg-

$ viresclient set_token
Enter access token: VymMHhWjZ-9nSVs-FuPC27ca8C6cOyij

Using SwarmRequest() without the url parameter will use the default URL set above. To access a non-default server the URL parameter must be used:

from viresclient import SwarmRequest

# request using the default server (
request = SwarmRequest()

# request to an alternative, non-default server
request = SwarmRequest(url="")

The older HTTP basic access authentication (i.e. username + password) is still available on the DICS staging server and these credentials can also be configured:

$ viresclient set_password
Enter username [jovyan]: <username>
Enter password: ***********

However, this interface is deprecated and it will be removed in future and it is recommended to switch to the token-based authentication.