2.0.1 • Published 5 years ago

superagent-d2l-session-auth v2.0.1

Weekly downloads
54
License
Apache-2.0
Repository
github
Last release
5 years ago

superagent-d2l-session-auth

NPM version Build status Coverage Status

A superagent plugin that adds D2L auth headers

Usage

var request = require('superagent'),
    auth = require('superagent-d2l-session-auth')();

request
    .get('/d2l/api/lp/1.5/users/whoami')
    .use(auth)
    .end(function(err, res) {
        if(err) {
           console.log('I always check for errors! ' + err.status + ' ' + err.response);
           return;
        }
        var user = res.body;
        console.log('Hello, ' + user.FirstName + ' ' + user.LastName);
    });

For strictly iframed applications, consider requiring superagent-d2l-session-auth/framed instead.

API


auth([Object options]) -> Function

The export is a factory function which creates the superagent plugin. The result of this call is what should be passed into .use.

Option: scope String (*:*\:*)

You may optionally specify scope(s) desired on the requested token. This option is passed directly into the backing frau-jwt library.

Option: trustedHost String

You may optionally specify an additional host which is trusted and which authorization tokens should be sent to. This should be generally unnecessary, and should only be an instance of Brightspace.

var auth = require('superagent-d2l-session-auth')({
	trustedHost: 'school.brightspace.com'
});

request
	.get('https://school.brightspace.com/api')
	.use(auth)
	.end(/* ... */);

Contributing

  1. Fork the repository. Committing directly against this repository is highly discouraged.

    1. Make your modifications in a branch, updating and writing new unit tests as necessary in the spec directory.

      1. Ensure that all tests pass with npm test

      2. rebase your changes against master. Do not merge.

      3. Submit a pull request to this repository. Wait for tests to run and someone to chime in.

Code Style

This repository is configured with EditorConfig and ESLint rules.