0.0.4 • Published 8 years ago

passport-weimob v0.0.4

Weekly downloads
-
License
MIT
Repository
-
Last release
8 years ago

Passport-Weimob

copied and revised from passport-weimob

Passport strategy for authenticating with Weimob using the OAuth 2.0 API.

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

Install

$ npm install passport-weimob

Usage

Configure Strategy

The Weimob authentication strategy authenticates users using a Weimob 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.

passport.use(new WeimobStrategy({
    clientID: WEIMOB_CLIENT_ID,
    clientSecret: WEIMOB_CLIENT_SECRET,
    callbackURL: "http://127.0.0.1:3000/auth/weimob/callback"
  },
  function(accessToken, refreshToken, profile, done) {
    User.findOrCreate({ weimobId: profile.id }, function (err, user) {
      return done(err, user);
    });
  }
));

Authenticate Requests

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

For example, as route middleware in an Express application:

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

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

License

The MIT License

Copyright (c) 2016 gli.cn

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago