Social Auth throwing error - How to fix?

I am facing issue during the social auth. after auth it is throwing below error. Better Auth Error We encountered an issue while processing your request. Please try again or contact the application owner if the problem persists. in the server, ERROR [Better Auth]: State Mismatch. Verification not found
socialProviders: {
github: {
clientId: process.env.GITHUB_CLIENT_ID || "",
clientSecret: process.env.GITHUB_CLIENT_SECRET || "",
disableSignUp: process.env.GITHUB_DISABLE_SIGNUP === "true",
disableImplicitSignUp: process.env.GITHUB_DISABLE_IMPLICIT_SIGNUP === "true",
},
google: {
clientId: process.env.NEXT_PUBLIC_GOOGLE_CLIENT_ID || "",
clientSecret: process.env.GOOGLE_CLIENT_SECRET || "",
disableSignUp: process.env.GOOGLE_DISABLE_SIGNUP === "true",
disableImplicitSignUp: process.env.GOOGLE_DISABLE_IMPLICIT_SIGNUP === "true",

},
},

socialProviders: {
github: {
clientId: process.env.GITHUB_CLIENT_ID || "",
clientSecret: process.env.GITHUB_CLIENT_SECRET || "",
disableSignUp: process.env.GITHUB_DISABLE_SIGNUP === "true",
disableImplicitSignUp: process.env.GITHUB_DISABLE_IMPLICIT_SIGNUP === "true",
},
google: {
clientId: process.env.NEXT_PUBLIC_GOOGLE_CLIENT_ID || "",
clientSecret: process.env.GOOGLE_CLIENT_SECRET || "",
disableSignUp: process.env.GOOGLE_DISABLE_SIGNUP === "true",
disableImplicitSignUp: process.env.GOOGLE_DISABLE_IMPLICIT_SIGNUP === "true",

},
},

client code,
await signIn.social({
provider: "google",
callbackURL: "/dashboard",
},
{
onSuccess: (data) => {
console.log("Login successful", data);
router.push("/dashboard");
toast.success("Login successful");
setLoading(false);
},
onError: ({ error }) => {
console.log("Login failed", error);
toast.error("Login failed", {
description: error.message,
});
setLoading(false);
},
}).catch(({ error }) => {
console.error("Error signing in:", error);
toast.error("Something went wrong", {
description: error.message,
});
setLoading(false);
});
}
await signIn.social({
provider: "google",
callbackURL: "/dashboard",
},
{
onSuccess: (data) => {
console.log("Login successful", data);
router.push("/dashboard");
toast.success("Login successful");
setLoading(false);
},
onError: ({ error }) => {
console.log("Login failed", error);
toast.error("Login failed", {
description: error.message,
});
setLoading(false);
},
}).catch(({ error }) => {
console.error("Error signing in:", error);
toast.error("Something went wrong", {
description: error.message,
});
setLoading(false);
});
}
No description
2 Replies
fud0w
fud0w3mo ago
Make sure env files are correct and In the Google cloud console for Google account login put your site link on the allow access
Red Ranger
Red RangerOP3mo ago
I have done that. but still facing the same issue.

Did you find this page helpful?