Progress so far
This commit is contained in:
40
app/api/auth/[...nextauth]/options.ts
Normal file
40
app/api/auth/[...nextauth]/options.ts
Normal file
@ -0,0 +1,40 @@
|
||||
import type { NextAuthOptions } from "next-auth";
|
||||
import TwitchProvider from "next-auth/providers/twitch";
|
||||
|
||||
export interface TwitchProfile extends Record<string, any> {
|
||||
sub: string
|
||||
preferred_username: string
|
||||
email: string
|
||||
picture: string
|
||||
}
|
||||
|
||||
export const options: NextAuthOptions = {
|
||||
providers: [
|
||||
TwitchProvider({
|
||||
clientId: process.env.TWITCH_CLIENT_ID as string,
|
||||
clientSecret: process.env.TWITCH_CLIENT_SECRET as string,
|
||||
authorization: {
|
||||
params: {
|
||||
scope: "openid user:read:email",
|
||||
claims: {
|
||||
id_token: {
|
||||
email: null,
|
||||
picture: null,
|
||||
preferred_username: null,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
idToken: true,
|
||||
profile(profile) {
|
||||
return {
|
||||
id: profile.sub,
|
||||
name: profile.preferred_username,
|
||||
email: profile.email,
|
||||
image: profile.picture,
|
||||
}
|
||||
},
|
||||
})
|
||||
],
|
||||
secret: process.env.NEXTAUTH_SECRET
|
||||
}
|
6
app/api/auth/[...nextauth]/route.ts
Normal file
6
app/api/auth/[...nextauth]/route.ts
Normal file
@ -0,0 +1,6 @@
|
||||
import NextAuth from 'next-auth'
|
||||
import { options } from './options'
|
||||
|
||||
const handler = NextAuth(options)
|
||||
|
||||
export { handler as GET, handler as POST }
|
Reference in New Issue
Block a user