Google and GitHub Provider in NextAuth returns the session as "null"
Unanswered
Santhosh Prabhakaran posted this in #help-forum
I'm using NextAuth in my NextJS 13 application. I've used Google, GitHub and Credentials provider for the user authentication. The credentials provider is working fine. But when I login using Google or GitHub, I could able to select the account. But the session returns null. Also the strange thing is the session returns in my terminal. But in application it doesn't.
My "app/api/auth/[...nextauth]/route.ts" file looks like,
And the login buttons looks like,
Any help on this would be appreciated.
My "app/api/auth/[...nextauth]/route.ts" file looks like,
export const authOptions: AuthOptions = {
adapter: PrismaAdapter(prisma),
providers: [
GoogleProvider({
clientId: process.env.GOOGLE_CLIENT_ID as string,
clientSecret: process.env.CLIENT_SECRET as string,
}),
GithubProvider({
clientId: process.env.GITHUB_CLIENT_ID as string,
clientSecret: process.env.GITHUB_CLIENT_SECRET as string,
}),
CredentialsProvider({
name: "credentials",
credentials: {
email: { label: "email", type: "text", placeholder: "email" },
password: {
label: "password",
type: "password",
placeholder: "Password",
},
},
async authorize(credentials) {
//Credentials code.....
return user;
},
}),
],
pages: {
signIn: "/",
},
session: {
strategy: "jwt",
},
secret: process.env.NEXTAUTH_SECRET,
debug: process.env.NODE_ENV === "development",
};
const handler = NextAuth(authOptions);
export { handler as GET, handler as POST };And the login buttons looks like,
<button onClick={() => signIn("google")}
className="p-3 w-full border-2 border-black font-semibold rounded-md flex flex-row items-center justify-center relative">Any help on this would be appreciated.
1 Reply
Grass Carrying Wasp
@Santhosh Prabhakaran did credential provider worked?