0.4.4 • Published 9 years ago

oneid v0.4.4

Weekly downloads
71
License
-
Repository
-
Last release
9 years ago

Install:

Install the 'oneid' package using NPM.

NPM

npm install oneid

Use

Include the 'oneid' package in your Node application.

var oneid = require('oneid');

If you've already obtained OneID API credentials, create your client using the oneid.getClient() method.

var client = oneid.getClient(API_ID, API_KEY)

Otherwise, don't use any parameters and then use the register() method to generate some fresh credentials.

var client = oneid.getClient()

client.register(function(response) {
  // {
  //   "API_KEY": "noscJaqlagYS/cDAijsbNr==",
  //   "API_ID": "cf438e4e-a7d0-49f4-b85e-6182ec3704cb"
  // }
  client.setCredentials(response.API_ID, response.API_KEY)
})

Then set up a route in your Node application that matches the challenge callback used by the OneID JavaScript API.

app.post('/auth', function(req, res) {
  client.validate(req.body, function(oneid_res) {

    if (oneid_res.isValid()) {

      // save or update user record here

      res.status(200).json({
        errorcode: 0,
        error: "success",
        valid: true
      });
    }
    else {
      res.status(200).json({
        errorcode: -99,
        error: oneid_res.getResponse() || "login not authorized",
        valid: false
      });
    }
  })
})
0.4.4

9 years ago

0.4.3

11 years ago

0.4.2

11 years ago

0.4.1

11 years ago

0.4.0

11 years ago

0.3.3

11 years ago

0.3.2

11 years ago

0.3.1

11 years ago

0.3.0

11 years ago

0.2.1

11 years ago

0.2.0

11 years ago

0.1.2

11 years ago

0.1.1

11 years ago

0.1.0

11 years ago