All Projects → IvanWei → passport-line-auth

IvanWei / passport-line-auth

Licence: MIT License
Line authentication strategy for Passport and Node.js.

Programming Languages

javascript
184084 projects - #8 most used programming language
Pug
443 projects

Projects that are alternatives of or similar to passport-line-auth

colortest
Quickly show all your terminal colors
Stars: ✭ 66 (+112.9%)
Mutual labels:  line
android-charts
A curated list of Android Chart libraries.
Stars: ✭ 69 (+122.58%)
Mutual labels:  line
clova-cek-sdk-java
SDK of the Clova CEK for Java
Stars: ✭ 13 (-58.06%)
Mutual labels:  line
line-sdk-unity
Provides a modern way of implementing LINE APIs in Unity games, for iOS and Android.
Stars: ✭ 84 (+170.97%)
Mutual labels:  line
react-liff
A react context provider for LIFF (LINE Front-end Framework)
Stars: ✭ 22 (-29.03%)
Mutual labels:  line
ucollage
An extensible command line image viewer inspired by vim
Stars: ✭ 161 (+419.35%)
Mutual labels:  line
react-node-twitter-login
Demo application that shows how to enable Twitter login with React on frontend and Node.js/Express on backend
Stars: ✭ 34 (+9.68%)
Mutual labels:  passport
bot-line-indonesian-summarizer
Tugas NLP UB Filkom 2017
Stars: ✭ 20 (-35.48%)
Mutual labels:  line
yelp-camp
A Node.js web application project from the Udemy course - The Web Developer Bootcamp by Colt Steele
Stars: ✭ 36 (+16.13%)
Mutual labels:  passport
LMGraphView
LMGraphView is a simple and customizable graph view for iOS.
Stars: ✭ 61 (+96.77%)
Mutual labels:  line
passport-yandex
Yandex authentication strategy for Passport and Node.js.
Stars: ✭ 19 (-38.71%)
Mutual labels:  passport
Laravel-Ecommerce-API
Lite E-Commerce API
Stars: ✭ 32 (+3.23%)
Mutual labels:  passport
teanjs
🔥 TypeORM - Express - Angular 8 - NestJS Server Side Rendering (SSR) 😺
Stars: ✭ 62 (+100%)
Mutual labels:  passport
line-sdk-android
LINE SDK for Android lets you integrate LINE into your Android app to create a more engaging experience for your users.
Stars: ✭ 101 (+225.81%)
Mutual labels:  line
line-login-sdk-go
LINE Login GO SDK (Original Social API SDK, It has been migrated into LINE login 2.1 after 2020/11/12)
Stars: ✭ 21 (-32.26%)
Mutual labels:  line
ng-nest-cnode
Angular 10 Front-End and Nestjs 7 framework Back-End build Fullstack CNode
Stars: ✭ 17 (-45.16%)
Mutual labels:  passport
clova-cek-sdk-nodejs
SDK of the Clova CEK for Node.js
Stars: ✭ 35 (+12.9%)
Mutual labels:  line
gnlTester
Tester for the get_next_line project of 42 school
Stars: ✭ 87 (+180.65%)
Mutual labels:  line
system information school
Build website using laravel as backend, vue js as front end and full request using api with middleware api passport.
Stars: ✭ 17 (-45.16%)
Mutual labels:  passport
line-richmenus-manager
LINE Rich Menus Manager
Stars: ✭ 19 (-38.71%)
Mutual labels:  line

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',
    prompt: 'consent',
    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.
prompt String Optional null Used to force the consent screen to be displayed even if the user has already granted all requested permissions. 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/>

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].