Home:ALL Converter>next-auth FirestoreAdapter not connecting to backend

next-auth FirestoreAdapter not connecting to backend

Ask Time:2022-10-16T23:50:21         Author:LonelySoul

Json Formatter

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.

Author:LonelySoul,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/74088521/next-auth-firestoreadapter-not-connecting-to-backend
yy