Get current workspace without the need for token

Description of the limitation and why it is relevant to address

As a developer I want to be able to access the current workspace (Workspace object) from within the workspace (for example by calling API().get_current_workspace()) so that I can use the workspace information (such as name, visibility, app version, …) in my app.

Current workarounds

Currently, one can access the “current” workspace by calling

# workspace_id is available via kwargs
API(token="TOKEN").get_workspace(workspace_id)

Notice that token needs to be provided, otherwise it does not work. However, I don’t think that accessing the workspace from within the workspace should require a token. I don’t feel comfortable having the token as an environment variable for the app, as it can potentially be misused.

Proposed design

This can be done by:

  • Adding a “get_current_workspace()” method to API;
  • Allowing the workspace id of the current workspace to be passed to API().get_workspace(workspace_id) without the need to provide the api token.