I am trying to implement the next-auth to authenticate and store user details through #GoogleProvider.
For some reason, the app is not connecting to the backend. I changed the firestore security rules to all, but the problem remains.
[...nextauth].js
import { FirestoreAdapter } from '@next-auth/firebase-adapter';
import NextAuth from 'next-auth';
import GoogleProvider from 'next-auth/providers/google';
import { app, db } from '../../../config/firebase';
export default NextAuth({
providers: [
GoogleProvider({
clientId: process.env.GOOGLE_CLIENT_ID,
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
}),
],
adapter: FirestoreAdapter({
apiKey: '...',
authDomain: '...',
projectId: '...',
storageBucket: '...',
databaseURL: '...',
messagingSenderId: '...',
appId: '...',
}),
debug: true,
});
firebase.js
import { initializeApp, getApp, getApps } from 'firebase/app';
import { getAuth } from 'firebase/auth';
import { getFirestore } from 'firebase/firestore';
import { initializeFirestore } from 'firebase/firestore';
// Your web app's Firebase configuration
const firebaseConfig = {
apiKey: '...',
authDomain: '...',
projectId: '...',
storageBucket: '...',
messagingSenderId: '...',
appId: '...',
measurementId: '...',
};
const app = initializeApp(firebaseConfig);
const auth = getAuth(app);
const db = getFirestore(app);
export { app, auth, db };
**firestore security rules **
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if true;
}
}
}
Error
@firebase/firestore: Firestore (9.12.1): Could not reach Cloud Firestore backend. Connection failed 1 times. Most recent error: FirebaseError: [code=permission-denied]: Permission denied: Consumer 'project:undefined' has been suspended.