Configuration

Use configuration to set up API keys for a school (or multiple schools)

Getting Started

After installation, the next step is to enable mbpy to use a school's API key. In ManageBac, create a token with at least read permissions for all endpoints, and copy the token value. Then:

mbpy config new

Does it say command not found? If you just installed it, you'll need to open a new terminal window.

You will then be promopted to enter the subdomain, and the token.

When complete, enter the following:

mbpy config show

The above command reports all configuration information:

                               mbpy configuration
                             β•·
  name                       β”‚ value
╺━━━━━━━━━━━━━━━━━━━━━━━━━━━━┿━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╸
  subdomain                  β”‚ demo
╢────────────────────────────┼──────────────────────────────────────────────────╴
  token (last 4 digits)      β”‚ daa0
╢────────────────────────────┼──────────────────────────────────────────────────╴
  Root Directory             β”‚ ~/some/path/here
╢────────────────────────────┼──────────────────────────────────────────────────╴
  Scripts Directory          β”‚ ~/some/path/here/mbpy/scripts
╢────────────────────────────┼──────────────────────────────────────────────────╴
  Path to config file        β”‚ ~/some/path/here/mbpy/conf/demo.py
╢────────────────────────────┼──────────────────────────────────────────────────╴
  Path to database           β”‚ ~/some/path/here/mbpy/data/demo.db
╢────────────────────────────┼──────────────────────────────────────────────────╴

Configuration complete! Learn how to pull data from the API by heading over to "Importing":

Importing

Switching schools

Whenever mbpy starts up, it uses the indicated configuration file, whose contents include the API token given for mbpy config new.

Security note: The API token is stored in plain text in the configuration file. Access to this file should be restricted.

If you set up more than one school, and need to switch schools, you can use the following command:

mbpy config use subdomain

That will tell mbpy to use the configuration file associated with the subdomain name you previously input.

To see a list of all subdomains available:

mbpy config list

Expliciit configuration

The above demonstrates how to use "implicit" configuration, where mbpy config use selects the subdomain, and then every subsequent mbpy command uses that configuration (until mbpy config use is invoked).

If you would prefer to explicitly indicate which subdoman, you can set the MBPY_SUBDOMAIN variable:

mbpy --subdomain abc …

That will instruct mbpy to use the configuration file, the same as if you first did mbpy config use abc.

Last updated