Skip to content

Instantly share code, notes, and snippets.

@eniodev
Created August 3, 2023 01:00
Show Gist options
  • Select an option

  • Save eniodev/cc2eff2a320690965182b07026d6e77e to your computer and use it in GitHub Desktop.

Select an option

Save eniodev/cc2eff2a320690965182b07026d6e77e to your computer and use it in GitHub Desktop.
next auth usage : )
// 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