Oauthcallback error, next auth, suddenly stopped working
Unanswered
Waterman posted this in #help-forum
WatermanOP
So when I log in through google using next auth I just get redirected to http://localhost:3000/api/auth/signin?error=OAuthCallback
the google credentials are set to the correct values, I show them in picture
error:
When I click login I use this:
more code:
the google credentials are set to the correct values, I show them in picture
error:
https://next-auth.js.org/errors#oauth_callback_error invalid_client (Unauthorized) {
error: OPError: invalid_client (Unauthorized)
at processResponse (webpack-internal:///(sc_server)/./node_modules/openid-client/lib/helpers/process_response.js:35:19)
MORE ERROR INFO HERE BUT MESSAGE TO LONG
route/module.js:265:37) {
name: 'OAuthCallbackError',
code: undefined
},
providerId: 'google',
message: 'invalid_client (Unauthorized)'
}When I click login I use this:
onClick={(e) => {
e.preventDefault();
signIn("google", {
callbackUrl: "/",
});
}}more code:
export const authOptions: NextAuthOptions = {
providers: [
GoogleProvider({
clientId: process.env.GOOGLE_ID as string,
clientSecret: process.env.GOOGLE_SECRET as string,
}),
],
adapter: MongoDBAdapter(clientPromise),
callbacks: {
session: ({ session, token, user }) => {
if (
process.env.EMAILS &&
session?.user?.email &&
process.env.EMAILS.includes(session.user.email)
) {
return session;
} else {
return Promise.reject(false);
}
},
},
};
const handler = NextAuth(authOptions);
export { handler as GET, handler as POST };