1.0.1 • Published 5 years ago

passport-line-token v1.0.1

Weekly downloads
88
License
MIT
Repository
github
Last release
5 years ago

passport-line-token

Passport strategy for authenticating with Line access tokens using the OAuth 2.0 API. Based on Line Social API v2.1

Installation

$ npm install --save passport-line-token

Usage

Configure Strategy

var LineTokenStrategy = require('passport-line-token');

passport.use(new LineTokenStrategy({
    clientID: LINE_CHANNEL_ID,
    clientSecret: LINE_CHANNEL_SECRET,
  }, function(accessToken, refreshToken, profile, done) {
    User.findOrCreate({lineId: profile.id}, function (error, user) {
      return done(error, user);
    });
  }
));

Authenticate Requests

Use passport.authenticate(), specifying the 'line-token' strategy, to authenticate requests.

app.post('/auth/line/token',
  passport.authenticate('line-token'),
  function (req, res) {
    // do something with req.user
    res.send(req.user? 200 : 401);
  }
);

Reference

License

The MIT License