#NexrAuth: OAuthCallbackError: failed to validate JWT signature

3 messages · Page 1 of 1 (latest)

grizzled basin
#
[next-auth][error][OAUTH_CALLBACK_ERROR] 
https://next-auth.js.org/errors#oauth_callback_error failed to validate JWT signature {
  error: 985 | export default "";
                     ^
OAuthCallbackError: failed to validate JWT signature
 code: "undefined"

      at asyncFunctionResume (native:1:1)
      at promiseReactionJobWithoutPromiseUnwrapAsyncContext (native:1:1)
      at promiseReactionJob (native:1:1)
      at processTicksAndRejections (native:1:1)
,
  providerId: "google",
  message: "failed to validate JWT signature",
}

code:

import clientPromise from "@/libs/mongodb";
import Google from "next-auth/providers/google";
import type { NextAuthOptions } from "next-auth";
import { MongoDBAdapter } from "@auth/mongodb-adapter";
import { Adapter } from "next-auth/adapters";
export const authOptions: NextAuthOptions = {
  providers: [
    Google({
      clientId: process.env.GOOGLE_CLIENT_ID as string,
      clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
      profile(profile) {
        return {
          id: profile.sub,
          name: profile.name,
          email: profile.email,
          image: profile.picture,
        };
      },
    }),
  ],
  secret: process.env.NEXTAUTH_SECRET as string,
  session: {
    strategy: "jwt",
    maxAge: 30 * 24 * 60 * 60,
  },
  jwt: {
    secret: process.env.NEXTAUTH_SECRET as string,
  },
  debug: process.env.NODE_ENV === "development",
  useSecureCookies: false, // Set to true if using HTTPS
  callbacks: {
    async signIn() {
      return true;
    },
    async session({ session, token }) {
      session.user = token.user as any;
      return session;
    },
    async jwt({ token, user }) {
      if (user) {
        token.user = user;
      }
      return token;
    },
  },
  adapter: MongoDBAdapter(clientPromise) as Adapter,
};

all .env are valid

outer carbonBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

grizzled basin
#

Can't figure out why isn't working.