nbox.auth
This code is used to manage the authentication of the entire nbox
package. For authentication it will create a .nbx
in the user's home directory (~/.nbx
, in case of linux) and store a file called secrets.json
. This folder will also contain more information and files that are used elsewhere as well ex. files generated when takling to any instance.
Users can chose to set configs at a global level for convenience. Here's a list of configs that can be set:
global.workspace_id = '' # this will set the default workspace id for all commands, users can override this by passing the --workspace-id
flag
Functions
Initialize the secret object. This is a singleton object that can be used across multiple processes.
Get the auth token for the current user.
Classes
Single source for all the secrets file. Can persist across multiple processes.
- item -
The item to get the value for
- default -
The default value to return if the item is not found
- reload -
If True, reload the secrets file before getting the value
Get the value of the item from the secrets file.
Returns:
any
: The value of the item or the default value if the item is not found
- item -
The item to put the value for
- value -
The value to put
- persist -
If True, persist the secrets file after putting the value
Put the value of the item in the secrets file. If no value
or persist
is specified, this is a no-op.