Skip to content
master
Switch branches/tags
Go to file
Code

Latest commit

Bumps [pug](https://github.com/pugjs/pug) from 3.0.0 to 3.0.1.
- [Release notes](https://github.com/pugjs/pug/releases)
- [Commits](https://github.com/pugjs/pug/compare/pug@3.0.0...pug@3.0.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
84b0a10

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

passport-line-auth

Build Status codecov Greenkeeper badge

NPM

Package Quality

Passport strategy for authenticating with LINE using the OAuth 2.0 API and OpenID Connect.

How to Install

npm

npm install passport-line-auth --save

Yarn

yarn add passport-line-auth

Usage

Create an Service

Before using passport-line-auth, you must register an Services with LINE. If you have not already done so, a new services can be created at LINE Developers. Your service will be issued an channel ID and channel secret, which need to be provided to the strategy. You will also need to configure a redirect URI which matches the route in your service.

Configure Strategy

The LINE authentication strategy authenticates users using a LINE account and OAuth 2.0 tokens. The channel ID and secret obtained when creating an service are supplied as options when creating the strategy. The strategy also requires a verify callback, which receives the access token and optional refresh token, as well as profile which contains the authenticated user's LINE profile. The verify callback must call cb providing a user to complete authentication.

  • [Part 1] Sample Code
passport.use(new LineStrategy({
    channelID: LINE_CHANNEL_ID,
    channelSecret: LINE_CHANNEL_SECRET,
    callbackURL: "http://localhost:3000/auth/line/callback",
    scope: ['profile', 'openid'],
    botPrompt: 'normal',
    uiLocales: 'en-US',
  },
  function(accessToken, refreshToken, profile, cb) {
    User.findOrCreate({ lineId: profile.id }, function (err, user) {
      return cb(err, user);
    });
  }
));
  • [Part 2] Sample Code
passport.use(new LineStrategy({
    channelID: LINE_CHANNEL_ID,
    channelSecret: LINE_CHANNEL_SECRET,
    callbackURL: "http://localhost:3000/auth/line/callback",
    scope: ['profile', 'openid', 'email'],
    botPrompt: 'normal',
    uiLocales: 'en-US',
  },
  function(accessToken, refreshToken, params, profile, cb) {
    var email = jwt.decode(params.id_token)
    User.findOrCreate({ lineId: profile.id }, function (err, user) {
      return cb(err, user);
    });
  }
));

Options

Parameter Type Required Default Description
channelID String Required Channel's Id by LINE
channelSecret String Required Channel's secret by LINE
callbackURL String Required URL that users are redirected to after authentication and authorization. Must match one of the the callback URLs registered for your channel in the console.
scope Array Required ['profile', 'openid'] Permissions granted by the user. Set value to either profile, openid or email. If
botPrompt String Optional null Displays an option to add a bot as a friend during login. Set value to either normal or aggressive. For more information, see Linking a bot with your LINE Login channel.
uiLocales String Optional null Display language for LINE Login screens. For more information, see Linking a bot with your LINE Login channel.

Response

Name Type Description
accessToken String Access token. Valid for 30 days.
refreshToken String Token used to get a new access token. Valid up until 10 days after the access token expires.
idToken String JWT that includes information about the user. This field is returned only if openid is specified in the scope. For more information, see ID tokens.

Exmaple

First time, you need set channel id, secret and redirect uri at Exmaple, then install packages and npm start.

Reference

License

The MIT License

Copyright(c)2019 Ivan Wei (Wei, Hong-Lin) <https://blog.ivanwei.co/>

About

Line authentication strategy for Passport and Node.js.

Topics

Resources

License