passport-restogram-oauth2

Restogram (OAuth2) authentication strategies for Passport.

npm install passport-restogram-oauth2
12 downloads in the last month

Passport-Restogram-OAuth

Passport strategies for authenticating with Restogram using OAuth 2.0.

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

Install

$ npm install passport-restogram-oauth2

Usage

Configure Strategy

The Restogram OAuth 2.0 authentication strategy authenticates users using a Restogram account and OAuth 2.0 tokens. The strategy requires a verify callback, which accepts these credentials and calls done providing a user, as well as options specifying a client ID, client secret, and callback URL.

var RestogramStrategy = require('passport-restogram-oauth').OAuth2Strategy;

passport.use(new RestogramStrategy({
    clientID: RESTOGRAM_CLIENT_ID,
    clientSecret: RESTOGRAM_CLIENT_SECRET,
    callbackURL: "http://127.0.0.1:3000/auth/restogram/callback"
  },
  function(accessToken, refreshToken, profile, done) {
    User.findOrCreate({ restogramId: profile.id }, function (err, user) {
      return done(err, user);
    });
  }
));

Authenticate Requests

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

For example, as route middleware in an Express application:

app.get('/auth/restogram',
  passport.authenticate('restogram'));

app.get('/auth/restogram/callback',
  passport.authenticate('restogram', { failureRedirect: '/login' }),
  function(req, res) {
    // Successful authentication, redirect home.
    res.redirect('/');
  });

Examples

TBD.

Tests

$ npm install --dev
$ make test

Credits

License

The MIT License

Copyright (c) 2013 Bikinapps [http://bikinapps.com/](http://bikinapps.com/)

npm loves you