Skip to content

Instantly share code, notes, and snippets.

@jukbot
Last active March 11, 2024 03:20
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jukbot/7e7a2155f323425de0b72f91faf637b4 to your computer and use it in GitHub Desktop.
Save jukbot/7e7a2155f323425de0b72f91faf637b4 to your computer and use it in GitHub Desktop.
Sample Line Login v2.1 with NextAuth.js
// Learn more https://next-auth.js.org/configuration/providers
import type { NextApiRequest, NextApiResponse } from 'next'
import NextAuth from 'next-auth'
import Providers from 'next-auth/providers'
const options = {
providers: [
Providers.Facebook({
clientId: process.env.FACEBOOK_ID,
clientSecret: process.env.FACEBOOK_SECRET,
}),
Providers.Google({
clientId: process.env.GOOGLE_ID,
clientSecret: process.env.GOOGLE_SECRET,
}),
Providers.Email({
server: process.env.EMAIL_SERVER,
from: process.env.SMTP_FROM,
}),
{
id: 'line',
name: 'Line',
type: 'oauth',
version: '2.0',
scope: 'profile openid email',
params: {
grant_type: 'authorization_code'
},
accessTokenUrl: 'https://api.line.me/oauth2/v2.1/token',
authorizationUrl: 'https://access.line.me/oauth2/v2.1/authorize?response_type=code',
profileUrl: 'https://api.line.me/v2/profile',
openId: true,
profile: (profile) => {
return {
id: profile.sub,
name: profile.name,
email: profile?.email,
image: profile.picture
}
},
clientId: process.env.LINE_ID,
clientSecret: process.env.LINE_SECRET,
},
],
database: process.env.DATABASE_URL,
secret: process.env.SECRET,
},
}
export default (req: NextApiRequest, res: NextApiResponse) => NextAuth(req, res, options)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment