0.1.0 • Published 8 years ago

neuron-synapse v0.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

Neuron-Synapse

A library for Encentivize app writers for aquiring and managing Oauth2.0 app-tokens. The library will use an in-memory cache to ensure that tokens are not needlessly requested

installation

npm install --save neuron-synapse

Usage

Once you have your clientId and client Secret, in the root of your app (reccomended) add the following:

var neuronSynapse = require('neuron-synapse);
neuronSynapse.initialise({
    neuronBaseUrl: "<linkToNeuronBaseUrl>",
    clientId: "<yourClientId>",
    clientSecret: "<yourClientSecret>"
});

Then when you need a token for your app, simply use the following code snippet:

var neuronSynapse = require('neuron-synapse');
var programName = req.programName; // get the program name somehow, might be stored in config or based on the req.path etc
neuronSynapse.getClientToken({
	programName: programName,
    scope: "<Space seprated list of scopes you require>"
}, getTokenDone);

function getTokenDone(error, token) {
	if (error) {
		throw error; //Ensure you have graceful error handling
	}

... // call the Encentivize api using the supplied bearer token
})
0.1.0

8 years ago

0.0.14

9 years ago

0.0.12

10 years ago

0.0.11

10 years ago

0.0.10

10 years ago

0.0.9

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago