Created
August 3, 2023 01:00
-
-
Save eniodev/cc2eff2a320690965182b07026d6e77e to your computer and use it in GitHub Desktop.
next auth usage : )
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Next.js API route support: https://nextjs.org/docs/api-routes/introduction | |
| import NextAuth from 'next-auth/next'; | |
| import GoogleProvider from 'next-auth/providers/google' | |
| export const authOptions = { | |
| providers: [ | |
| GoogleProvider({ | |
| clientId: process.env.GOOGLE_CLIENT_ID as string, | |
| clientSecret: process.env.GOOGLE_CLIENT_SECRET as string, | |
| }), | |
| ], | |
| secret: process.env.JWT_SECRET, | |
| callbacks: { | |
| async jwt({ token, account }: any) { | |
| if (account) { | |
| token.id_token = account.id_token; | |
| } | |
| return token; | |
| }, | |
| async session({ session, token }: any) { | |
| if (session) { | |
| session.id_token = token.id_token; | |
| } | |
| return session; | |
| } | |
| } | |
| } | |
| export default NextAuth(authOptions); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment