Configuration

class Configuration(host: str, auth_host: str = 'https://auth.aiod.eu/aiod-auth/', auth_realm: str = 'aiod', auth_client_id: str = 'aiod-sdk', login_timeout: int = 300)[source]

Configuration class for the OuterRail SDK. Provides methods for specifying the host and handling authentication.

__init__(host: str, auth_host: str = 'https://auth.aiod.eu/aiod-auth/', auth_realm: str = 'aiod', auth_client_id: str = 'aiod-sdk', login_timeout: int = 300) Self[source]

Initializes a new Configuration instance.

Parameters:
  • host – (str): The url address that the SDK should connect to.

  • auth_host – (str): Url of the keycloak server providing auth logic of the SDK.

  • auth_realm – (str): The realm of the SSO for login.

  • auth_client_id – (str): The client id of the SDK.

Returns:

Initialized SDK configuration.

Return type:

Configuration

Example

>>> Configuration(host="https://rail.aiod.eu/api")
Configuration
login(persist: bool = False) None[source]

Get an API Key by prompting the user to log in through a browser.

IMPORTANT: This is a blocking function, and will poll the authentication server until authentication is completed or timeout_seconds have passed.

Parameters:
  • persist (bool, optional) – If set to true, the login session will persist between multiple executions of code

  • case (in which)

  • execution. (login() doesn't need to be called every)

  • background (In the)

  • key (the new api)

  • file (configuration)

Raises:

AuthenticationError – if authentication is unsuccessful in any way.

Example

>>> config = Configuration(host="https://rail.aiod.eu/api")
>>> config.login(persist=True)
# User is logged in and token is persisted to file.
logout() None[source]

Logs out the current user by invalidating the current token. Logout also erases the token persisted in a file created by login(persist=True).

Raises:
  • KeycloakPostError – if logout was unsuccessful.

  • KeycloakConnectionError – if connection to auth server failed.

Example

>>> config.logout()
# User is logged out and the file containing the token is erased.