How do I use the Canvas Data 2 Command Line Interface (CLI) Tool?
A small Command Line Interface (CLI) tool for syncing data from the Canvas Data API.
All of this needs to be done through your terminal (OSX/Linux), command prompt (Windows) or through the Bash terminal in the Windows Linux Sub system.
Download the Canvas Data 2 Command Line Interface (CLI) Tool
You can download the Python package from Python Package Manager and run: pip3 install instructure-dap-client. You can find the available commands in the Project description of the package manager.
To run Canvas Data 2, users must have Python 3.8, 3.9, 3.10 and the PIP package manager installed.
Store Client Credentials in Environment Variables
You can store the client credentials (Client ID and Client Secret), and the API base URL as permanent environmental variables (more secure) on your machine, thus the CLI tool will automatically invoke those when using it.
To do so, open any command-line interface (terminal), navigate to your root folder and configure the environment variables:
- You need to edit the file containing the environment variables, which might be different depending on the shell type you are using.
- For example, in case you use bash shell, in a terminal tab type open ~/.bash_profile. This will open the .bash_profile with your default text editor.
- Add the environment variables to the file opened. In a new row, type:: export DAP_API_URL=
- In a new row, type: DAP_CLIENT_ID='your_canvas_data_key'
- In a new row, type: export DAP_CLIENT_SECRET='your_canvas_data_secret'
- Some computers may require single or double quotes around the key and secret
- Save the file
- Restart your terminal
- Type printenv and press enter to check all your environment variables.
- Guide to setting environment variables
- Path will be DAP_API_URL, DAP_CLIENT_ID and DAP_CLIENT_SECRET.
- Key will be the associated Canvas Data 2 Key and Secret values to those paths.