I've set up next-auth with a google provider for my next.js application.
But I'm not seeing logged-in users or users being created after login into the app with google. Even if I set up the web client id and web client secret.
I can read and write documents in firestore without security rules but i can't get it with simple allow read, write: if request.auth != null; as there is no user in my firebase cloud console created when login in with next-auth.
Am I missing something or is it simply not production ready yet?
[...nextauth].js
import NextAuth from "next-auth";
import GoogleProvider from "next-auth/providers/google";
import { firebaseConfig } from "../../../src/lib/firebase";
// import { FirestoreAdapter } from "@next-auth/firebase-adapter";
export default NextAuth({
providers: [
GoogleProvider({
clientId: process.env.GOOGLE_WEB_CLIENT_ID,
clientSecret: process.env.GOOGLE_WEB_CLIENT_SECRET,
}),
],
pages: {
signIn: "/auth/sign-in",
},
// I'M NOT WITH WORKING THE ADAPTER AT THE MOMENT
// adapter: FirestoreAdapter({
// apiKey: "",
// authDomain: "",
// projectId: "",
// storageBucket: "",
// messagingSenderId: "",
// appId: "",
// measurementId: "",
// Optional emulator config (see below for options)
// emulator: {},
// }),
// ...
});
sign in
{Object.values(providers).map((provider) => (
<div key={provider.name}>
<button
className={styles.signInButton}
onClick={() => signIn(provider.id, { callbackUrl: "/" })}
>
Sign in with {provider.name}
</button>
</div>
))}
doc creation test
const docRef = await addDoc(collection(db, "tests"), {
fullName: values.fullName,
createdAt: serverTimestamp(),
});
*Seems like multiple people having this issue Link
*Same issue when working with adapters, I'm not using one at the moment but tried it without success Link