passport-hatena

0.0.2 • Public • Published

Passport-Hatena

===============

Passport strategy for authenticating with Hatena using the OAuth 1.0a API

This module can be used with passport in Node.js. You can integrate into below applications or frameworks. Connect-style middleware, including Express.

Install

$ npm install passport-hatena

Usage

Configuration Strategy

This Hatena passport module requires your application' id. You can get this id from Hatena Developer Center

Authorization Endpoint

passport.use(new HatenaStrategy({
    consumerKey: HATENA_CONSUMER_KEY,
    consumerSecret: HATENA_SECRET_KEY,
    callbackURL: "http://127.0.0.1:3000/auth/hatena/callback"
  },
  function(token, tokenSecret, profile, done) {
    User.findOrCreate({ hatenaId: profile.id }, function (err, user) {
      return done(err, user);
    });
  }
));

Authenticate Requests

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

For example, as route middleware in an Express application:

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

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

Examples

For a complete, working example, refer to the login example.

License

The MIT License

Dependencies (2)

Dev Dependencies (1)

Package Sidebar

Install

npm i passport-hatena

Weekly Downloads

1

Version

0.0.2

License

none

Last publish

Collaborators

  • horiuchi