HeliosSession

Manager for the authorization token required to access the Helios API.

class helios.core.session.Authentication(client_id, client_secret, api_url=None)[source]

Authentication API.

Parameters:
  • client_id (str) – API key ID.
  • client_secret (str) – API key secret.
  • api_url (str) – Override the default API URL.
get_access_token()[source]

Gets a new access token.

Returns:Helios API access token.
Return type:Token
get_current_user(token)[source]

Return a compact list of current token attributes, such as the token expiration date.

Parameters:token (Token) – A Helios Token.
Returns:Token attributes.
Return type:dict
Raises:ValueError – If current token is invalid or expired.
class helios.core.session.HeliosSession(client_id=None, client_secret=None, api_url=None, base_directory=None, max_threads=64, token_expiration_threshold=60, ssl_verify=True)[source]

Manages configuration and authentication details for the Helios APIs.

The session will handle acquiring and verifying tokens as well as various developer options.

Parameters:
  • client_id (str, optional) – API key ID.
  • client_secret (str, optional) – API key secret.
  • api_url (str, optional) – Override the default API URL.
  • base_directory (str, optional) – Override the base directory for storage of tokens and credentials.json file.
  • max_threads (int, optional) – The maximum number of threads allowed for batch calls.
  • token_expiration_threshold (int, optional) – The number of minutes to allow before token expiration. E.g. if the token will expire in 29 minutes and the threshold is set to 30, a new token will be acquired because expiration time is below the threshold.
  • ssl_verify (bool, optional) – Use SSL verification for all HTTP requests. Defaults to True.
auth_header

Authentication header for API requests.

client(name)[source]

Gets a core API instance using the current HeliosSession.

Parameters:name (str) – Name of API.
Returns:Core API instance.
get_new_token()[source]

Gets a new token for the current Helios session.

read_token()[source]

Reads token from file.

verify_token()[source]

Verifies that token has not expired.

If the token has expired a new token will be acquired.

write_token()[source]

Writes token to file.

class helios.core.session.Token(access_token, expires_in=None, **kwargs)[source]

Helios token.

Parameters:
  • access_token (str) – Access token.
  • expires_in (int) – Seconds until expiration. WARNING: this value can be misleading. If reading from a token file the value will not be current.
  • kwargs – Any other optional token attributes.
auth_header

Authentication header for API requests.

expiration

The expiration time.

expired

True if token is expired, False otherwise.

to_json()[source]

Serializes token to JSON.

Returns:JSON serialized string.
Return type:str