Skip to content

Config

The config parameter can be used to provide a dictionary containing the project configuration like user and password for basic auth or a bearer token.

Basic auth

The format of the dictionary for basic auth must be as this:

{
    "user": "user",
    "password": "password"
}

OAuth token

The format of the dictionary for bearer token must be as this:

{
    "client_id": "id",
    "access_token": "token",
    "refresh_token": "token"
}

Set manually credentials

In case you try to get a project without from the backend with invalid credentials, an exception will be raised. Because the backend client is a Singleton object, it will autoconfigure credentials at startup, so the only way to setup proper credentials once it fails to connect is to use the SDK method set_dhcore_env().

set_dhcore_env

Function to set environment variables for DHCore config. Note that if the environment variable is already set, it will be overwritten. It also ovverides the remote client configuration.

Parameters:

Name Type Description Default
endpoint str

The endpoint of DHCore.

None
user str

The user of DHCore.

None
password str

The password of DHCore.

None
access_token str

The access token of DHCore.

None
refresh_token str

The refresh token of DHCore.

None
client_id str

The client id of DHCore.

None

Returns:

Type Description
None

Example:

dh.set_dhcore_env(
    endpoint="https://some-digitalhub:8080",
    access_token="token"
)

Note that the set_dhcore_env() method ovverrides the environment variables and (if already instantiated) the credentials attributes of the backend client.