Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
OAuth npm package for Hatena
JavaScript
Branch: master

README.md

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

Something went wrong with that request. Please try again.