# canvas-request

> npm module for making api requests to canvas

Latest version **0.0.2** (published 2017-07-18) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install canvas-request
pnpm add canvas-request
yarn add canvas-request
bun add canvas-request
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2017-07-18 |
| First published | 2017-07-13 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+2 in 2 direct dependencies) |
| Install scripts | no |
| Author | Spencer Holman |
| Maintainers | brettbeatty, thatjoemoore, mhailstone, saholman, pauldeden |

## Links

- npm: https://www.npmjs.com/package/canvas-request
- Repository: https://github.com/byu-oit/canvas-request
- Homepage: https://github.com/byu-oit/canvas-request#readme
- Issues: https://github.com/byu-oit/canvas-request/issues
- npm.io page: https://npm.io/package/canvas-request

## Dependencies (2)

- [aws-sdk](https://npm.io/package/aws-sdk.md) ^2.83.0
- [request](https://npm.io/package/request.md) ^2.81.0

## Recent versions

- 0.0.2 (latest) — 2017-07-18
- 0.0.1 — 2017-07-13

## README

# canvas-request
###### This is a simple npm module for making API calls to Instructure's canvas.
## Usage
The following parameters are required either as environment variables or as parameters in the Parameter Store:

* CANVAS_CLIENT_ID
* CANVAS_CLIENT_SECRET
* CANVAS_REFRESH_TOKEN

If they are included in the parameter store, include the parameter_header in the config (see below) and set the credential_method to aws_ssm.  For example, if I have a parameter named "lms-event-integration.dev.CANVAS_CLIENT_ID" and another named "lms-event-integration.dev.CANVAS_CLIENT_SECRET" then my parameter_header would be "lms-event-integration.dev".  

If you are not using the parameter store, you must have those values set as environment variables.

```
var canvas = require('./index.js')
// var canvas_token = '<place your canvas token here>'
var canvas_config = {
    // 'token': canvas_token, // If you include the token in the config, you don't need the CANVAS_CLIENT_ID, CANVAS_CLIENT_SECRET or the CANVAS_REFRESH_TOKEN.  Omit to use aws_ssm or env_vars
    'credential_method': 'aws_ssm', // Either aws_ssm or env_vars
    'aws': { // include if using aws_ssm
        'parameter_header': 'lms-event-integration.dev',
        'region': 'us-west-2',
        'aws_params_location': 'file' // Either file (~/.aws/credentials) or env_vars
    }
}

var requestOptions = {
    'url': 'https://byu.test.instructure.com/api/v1/accounts/1/users',
    'method': 'GET',
    'headers': {
        'Accept': 'application/json'
    }
}

canvas(requestOptions, canvas_config, function(err, res, body) {
    if(err) {
        console.log(err)
    } else {
        console.log(body)
    }
})
```
NOTE: "aws-ssm" is used to fetch parameters stored in the Amazon Parameter Store.  For more information, see http://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-paramstore.html and http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SSM.html.

For more information on Canvas APIs see https://canvas.instructure.com/doc/api/index.html

## Issues
* One of the config items needs to be the canvas url.  Right now the byu one is hard coded.
* I need to add to the config a boolean to set whether the token is being passed in or whether to use the refresh token.  
    * If a token is being passed in, there is no need for the refresh token to be passed in.

## Future Work
* There probably isn't a need to get the aws parameters every time.  Can you set them as enviroment variables?

---
_Source: https://npm.io/package/canvas-request · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
