line-popup-login
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

LINE Login with Popup Modal

NPM version Software License GitHub Tests Action Status Total Downloads

This package status is experimental, it works on Windows 11 desktops but can't work on mobile, please don't use it for production.

Installation

Install the package:

npm i inertia-plugin
# or
yarn add inertia-plugin

Then add the callback page line-callback.html into the public folder (static assets folder):

<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>LINE OAuth 2 Callback</title>
</head>
<body>
  <script>
  const searchParams = window.location.search
    .replace(/^\?/, '')
    .split('&')
    .reduce((carry, item) => {
      const [key, value] = item.split('=')
      return { ...carry, [key]: value }
    }, {})

  window.opener.postMessage({
    command: 'close',
    data: searchParams,
  }, '*')
  </script>
</body>
</html>

Usage

Call lineAuthLogin() when you want to log in with LINE:

lineAuthLogin({
  client_id: YOUR_LINE_CHANNEL_ID,
  scope: 'profile openid',
  state: SET_RANDOM_TEXT,
  redirect_uri: `${location.origin}/line-callback.html`,
}).then(res => {
  console.log('Handle the LINE response', res)
}).catch(error => {
  console.error(error)
})

License

MIT LICENSE

Readme

Keywords

Package Sidebar

Install

npm i line-popup-login

Weekly Downloads

0

Version

0.2.0

License

MIT

Unpacked Size

9.89 kB

Total Files

7

Last publish

Collaborators

  • ycs77