Set up Google OAuth with next-auth and prepared for user table creation
This commit is contained in:
17
pages/api/auth/[...nextauth].js
Normal file
17
pages/api/auth/[...nextauth].js
Normal file
@@ -0,0 +1,17 @@
|
||||
import NextAuth from 'next-auth';
|
||||
import GoogleProvider from 'next-auth/providers/google';
|
||||
|
||||
export default NextAuth({
|
||||
providers: [
|
||||
GoogleProvider({
|
||||
clientId: process.env.GOOGLE_CLIENT_ID,
|
||||
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
|
||||
}),
|
||||
],
|
||||
callbacks: {
|
||||
async session({ session, token }) {
|
||||
session.user.id = token.sub;
|
||||
return session;
|
||||
},
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user