Next Auth Google provider

This commit is contained in:
Brad Traversy
2024-07-10 08:20:58 -04:00
parent 0b1c9aaa02
commit a255f02cd2
6 changed files with 223 additions and 6 deletions
+32
View File
@@ -0,0 +1,32 @@
import GoogleProvider from 'next-auth/providers/google';
export const authOptions = {
providers: [
GoogleProvider({
clientId: process.env.GOOGLE_CLIENT_ID,
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
authorization: {
params: {
prompt: 'consent',
access_type: 'offline',
response_type: 'code',
},
},
}),
],
callbacks: {
// Invoked on successful sign in
async signIn({ profile }) {
// 1. Connect to database
// 2. Check if user exists in database
// 3. If not, create user in database
// 4. return true to allow sign in
},
// Session callback function that modifies the session object
async session({ session }) {
// 1. Get user from database
// 2. Assign user id from database to session
// 3. return session
},
},
};