@alohahealth/micro-bluebutton
CMS Blue Button 2.0 OAuth for ZEIT Micro
Last updated 8 months ago by ajbarry .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @alohahealth/micro-bluebutton 
SYNC missed versions from official npm registry.

micro-bluebutton

BlueButton 2.0 OAuth Client for ZEIT micro

Add CMS BlueButton 2.0 authentication to your micro service in just a few keystrokes.

This module is graciously borrowed from, but not affiliated with the microauth collection.

Installation

npm install --save @alohahealth/micro-bluebutton
# or
yarn add @alohahealth/micro-bluebutton

Usage

  1. Register your application client on the Developer Sandbox
  2. Create the following micro app as app.js:
const { send } = require('micro')
const microBlueButton = require('micro-bluebutton')

const options = {
  dev: process.env.NODE_ENV !== 'production',
  clientId: 'CLIENT_ID',
  clientSecret: 'CLIENT_SECRET',
  callbackUrl: 'http://localhost:3000/auth/bluebutton/callback',
  path: '/auth/bluebutton',
}

const blueButtonAuth = microBlueButton(options)

// Third `auth` argument will provide error or the results of authentication
// so it will { err: errorObject } or
// { result: {
//     provider: 'bluebutton',
//     token: { /token response object },
//     user: { /userinfo response object },
// }}
const handler = async (req, res, auth) => {
  if (!auth) {
    return send(res, 404, 'Not Found')
  }

  if (auth.err) {
    // Error handler
    console.error(auth.err)
    return send(res, 403, 'Forbidden')
  }

  return `Hello ${auth.result.user.name}`
}

module.exports = blueButtonAuth(handler)

Run:

micro app.js
  1. Visit http://localhost:3000/auth/bluebutton
  2. Enter USERNAME: BBUser00000 and PASSWORD: PW00000!
  3. Click the ALLOW button when prompted by Blue Button
  4. See Hello Jane Doe as the response

Author

Adam Barry

Current Tags

  • 0.1.3                                ...           latest (8 months ago)

4 Versions

  • 0.1.3                                ...           8 months ago
  • 0.1.2                                ...           8 months ago
  • 0.1.1                                ...           8 months ago
  • 0.1.0                                ...           8 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 9
Last Day 0
Last Week 0
Last Month 0
Dependencies (4)
Dev Dependencies (2)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |