HTC Session

class rescalehtc.htcsession.HtcSession(workspace='default', config_folder_override=None)

Top level of rescalehtc, keeping the authentication state and allowing reauthentication as needed. This object needs to be passed into any function that will talk to the Rescale API.

Before instancing this class for the first time in a non-rescale environment such as your own machine or a VM, use the rauthenticate executable script that comes bundled with rescalehtc. This writes tokens to ~/.config/rescalehtc/ for later use.

In an interactive environment, do:

> rauthenticate --interactive

This will prompt you for API key.

If you’re using this package in a non-interactive environment (e.g. in a container), you may do

> rauthenticate

This will look for environment variables with either a RESCALE_HTC_REFRESH_TOKEN or RESCALE_API_TOKEN, which will be used to obtain the Bearer token used for later operations.

Parameters:
  • workspace – Optional: If you are working with multiple workspaces (which each has their own API key), then specify the workspace name here. This is required if you have more than 1 API key in ~/.config/rescalehtc/.

  • config_folder_override – Optional: Override the default configuration folder, which by default is ~/.config/.rescalehtc/.

get_bearer_token() BearerToken

Get a BearerToken object for the currently active Rescale HTC Bearer token, which is a JSON Web Token (JWT).

The returned object enables easy access to the claims in the JWT.