0

I tried to use next-auth to login with google , but it ran into an error and it said 'unable to verify the first certificate'.enter image description here

YouYi
  • 23
  • 1
  • 6

1 Answers1

0

this is what my google authentication looks like:

pages/api/auth/[...nextauth].ts
import NextAuth, { NextAuthOptions } from 'next-auth';
import GoogleProvider from 'next-auth/providers/google';

export const authOptions: NextAuthOptions = {
  providers: [
    GoogleProvider({
      clientId: process.env.GOOGLE_CLIENT_ID,
      clientSecret: process.env.GOOGLE_CLIENT_SECRET,
    }),
  ],
};
export default NextAuth(authOptions);

in the root directory, you should have .env.local where you should put GOOGLE_CLIENT_ID=your_ID and GOOGLE_CLIENT_SECRET=your_secret For more info, please follow https://next-auth.js.org/providers/google

Murad
  • 123
  • 1
  • 8