0.3.7 • Published 9 years ago

passport-smartthings v0.3.7

Weekly downloads
19
License
Apache 2.0
Repository
github
Last release
9 years ago

passport-smartthings

A Passport.js OAuth 2.0 strategy for Smart Things.

Passport strategy for authenticating with Smart Things using the OAuth 2.0 API.

This module lets you authenticate using Smart Things in your Node.js applications. By plugging into Passport, Smart Things authentication can be easily and unobtrusively integrated into any application or framework that supports Connect-style middleware, including Express.

Install

$ npm install passport-smartthings

Usage

Configure Strategy

var SmartThingsStrategy = require('passport-smartthings').Strategy

passport.use(new SmartThingsStrategy({
    clientID: SMARTTHINGS_CLIENT_ID,
    clientSecret: SMARTTHINGS_CLIENT_SECRET
}));

Authenticate Requests

Use passport.authenticate(), specifying the 'smartthings' strategy, to authenticate requests.

Note Smart Things requires the presence of a scope permission such as "app".

For example, as route middleware in an Express application:

app.get(
    '/auth/smartthings', 
    passport.authenticate('smartthings', { scope: ['app'] })
);

app.get('/auth/smartthings/callback',
    passport.authenticate('smartthings', { scope: ['app'] }),
    function(req, res) { 
        res.redirect('/'); 
    }
);

Extended Permissions

If you need extended permissions from the user, the permissions can be requested via the scope option to passport.authenticate().

For example, this authorization requests permission to the app tied to the clientID:

app.get(
    '/auth/smartthings', 
    passport.authenticate('smartthings', { scope: ['app'] })
);

Profile

The above configuration will populate the passport profile in session with the Smart Things access token and applicable api endpoints available to the logged in user for further api requests. The endpoints are as described in Step 8 of the Web Services Smart App documentation found here SmartApp Web Services Developers Guide. For example usage checkout examples/app.js dashboard express route.

0.3.7

9 years ago

0.3.6

9 years ago

0.3.5

9 years ago

0.3.4

9 years ago

0.3.3

9 years ago

0.3.2

9 years ago

0.3.1

9 years ago

0.3.0

9 years ago

0.2.9

9 years ago

0.2.8

9 years ago

0.2.7

9 years ago

0.2.6

9 years ago

0.2.5

9 years ago

0.2.4

9 years ago

0.2.3

9 years ago

0.2.2

9 years ago

0.2.1

9 years ago

0.2.0

9 years ago

0.1.9

9 years ago

0.1.8

9 years ago

0.1.7

9 years ago

0.1.6

9 years ago

0.1.5

9 years ago

0.1.4

9 years ago

0.1.3

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago