Skip to content

Ray0427/passport-line-token

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Passport strategy for authenticating with Line access tokens using the OAuth 2.0 API.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published