Wondering what’s next for npm?Check out our public roadmap! »

    passport-hatena-oauth

    1.0.0 • 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-oauth
    

    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('/');
      });
    

    License

    The MIT License

    Install

    npm i passport-hatena-oauth

    DownloadsWeekly Downloads

    20

    Version

    1.0.0

    License

    none

    Unpacked Size

    7.57 kB

    Total Files

    5

    Last publish

    Collaborators

    • avatar