summaryrefslogtreecommitdiff
path: root/src/pages
diff options
context:
space:
mode:
authorHATEC\SPVDEV001 <tri.susilo@altama.co.id>2023-08-09 10:45:53 +0700
committerHATEC\SPVDEV001 <tri.susilo@altama.co.id>2023-08-09 10:45:53 +0700
commit4cfe9157d64a76bf9913fe599d908497a18f5316 (patch)
treed5c8df003733bec5109817c6c48e5703664f3a8e /src/pages
parent4d021a4634a6bc84ee25f0d43cbc6450d94265f0 (diff)
google sign in
Diffstat (limited to 'src/pages')
-rw-r--r--src/pages/api/auth/[...nextauth].js40
1 files changed, 27 insertions, 13 deletions
diff --git a/src/pages/api/auth/[...nextauth].js b/src/pages/api/auth/[...nextauth].js
index f1d6a31f..6cc8a101 100644
--- a/src/pages/api/auth/[...nextauth].js
+++ b/src/pages/api/auth/[...nextauth].js
@@ -1,15 +1,29 @@
-import NextAuth from "next-auth/next";
-import GoogleProvider from "next-auth/providers/google"
+import NextAuth from 'next-auth/next'
+import GoogleProvider from 'next-auth/providers/google'
export default NextAuth({
- providers:[
- GoogleProvider({
- clientId: process.env.GOOGLE_CLIENT_ID,
- clientSecret: process.env.GOOGLE_CLIENT_SECRET,
- }),
- ],
- secret:process.env.JWT_SECRET
- // pages:{
- // signIn: '/login',
- // }
-}) \ No newline at end of file
+ providers: [
+ GoogleProvider({
+ clientId: process.env.GOOGLE_CLIENT_ID,
+ clientSecret: process.env.GOOGLE_CLIENT_SECRET
+ })
+ ],
+ callbacks: {
+ async jwt({ token, account }) {
+ // Persist the OAuth access_token to the token right after signin
+ if (account) {
+ token.accessToken = account.access_token
+ }
+ return token
+ },
+ async session({ session, token, user }) {
+ // Send properties to the client, like an access_token from a provider.
+ session.accessToken = token.accessToken
+ return session
+ }
+ },
+ secret:process.env.JWT_SECRET
+ // pages:{
+ // signIn: '/login',
+ // }
+})