Firebase Authentication: auth/auth-domain-config-required - javascript

I'm getting auth-domain-config-required errors when using firebase.auth().signInWithPopup(provider).
I've tried with Google and Facebook. I've tested on my hosted site, and it works fine. You can test it live: Quiver Chat Demo
I suspect there's a problem with localhost:3333... does it not like my port? I can't add a port to the Authorized domains list, and adding it to my authDomain: config doesn't help either.
Here's my auth code, but as you can see from the screenshots below, I tried a bunch of different authDomain values.
<script src="https://quiver-four.firebaseapp.com/__/firebase/4.6.2/firebase-app.js"></script>
<script src="https://quiver-four.firebaseapp.com/__/firebase/4.6.2/firebase-auth.js"></script>
<script>
// Initialize Firebase
var config = {
apiKey: "AIzaSyCzNxnQ6WCJKejq6SBd7NqhVskxEOmDq_Y",
authDomain: "quiver-four.firebaseapp.com",
databaseURL: "https://quiver-four.firebaseio.com",
projectId: "quiver-four",
storageBucket: "quiver-four.appspot.com",
messagingSenderId: "1082528354495"
};
firebase.initializeApp(config);
</script>
Attempting localhost:3333
Attempting localhost
Attempting quiver-four.firebaseapp.com
The domains are added

You must not be providing the correct authDomain in your Firebase app initialization configuration.
You can get that web snippet from the Firebase Console. The authDomain has the form projectName.firebaseapp.com.

I had the same problem and my solution was to have a file in the root firebase.js with all the connection configuration:
// Import the functions you need from the SDKs you need
import { initializeApp } from "firebase/app";
import { getFirestore } from "firebase/firestore";
import {getAuth} from 'firebase/auth'
import { getAnalytics } from "firebase/analytics";
// TODO: Add SDKs for Firebase products that you want to use
// https://firebase.google.com/docs/web/setup#available-libraries
// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
const firebaseConfig = {
apiKey: "xxxxxxx_xxx_R-xxx-CDxxxxcg",
authDomain: "qxxxxxx-xxxx.firebaseapp.com",
projectId: "xxxxxx-xxxxx",
storageBucket: "xxxxxxx-xxxx.appspot.com",
messagingSenderId: "xxxxxxx",
appId: "1:xxxxxxx:wxb:xxxxxxxxxxxxxx",
measurementId: "G-xxxxx"
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
const analytics = getAnalytics(app);
export const db = getFirestore(app);
export const auth = getAuth(app);

Related

src\firebase.js Line 20:14: 'firestore' is not defined no-undef Search for the keywords to learn more about each error

import firebase from 'firebase/compat/app';
import 'firebase/compat/auth';
import 'firebase/compat/firestore';
const firebaseConfig = {
apiKey: "AIzaSyA-1CDIgbhEIzl3OuyBVj07f23bHcGdhi4",
authDomain: "netflix2-9d006.firebaseapp.com",
projectId: "netflix2-9d006",
storageBucket: "netflix2-9d006.appspot.com",
messagingSenderId: "834718120256",
appId: "1:834718120256:web:add5fc25daf4729190a2a5"
};
const fireabaseApp = firebase.initializeApp(firebaseConfig);
const db = fireabaseApp.firestore();
const auth = firestore.auth();
export {auth} ;
export default db;
this is my firebase.js file i have used latest firebase version even though i have been facing issue with firestore pls guide thank you
this is my firebase.js file i have used latest firebase version even though i have been facing issue with firestore .
can anyone guide how can i import firestore from the firebase Thank you.

Error in Firebasse"assert.ts:128 Uncaught FirebaseError: Firebase: Error (auth/invalid-api-key)

Why do I have the error that it says invalid API keys?
This is the sample .env.local
REACT_APP_apiKey=AI**************JmXMKaFQQQrRzp4Q
REACT_APP_authDomain=sample-258a7.firebaseapp.com
REACT_APP_projectId=sample-258a7
REACT_APP_storageBucket=sample-258a7.appspot.com
REACT_APP_messagingSendearId=
REACT_APP_appId=1:1014069435807:web:04390779a92d4e3a4fb1aa
In another file:
import { initializeApp } from "firebase/app";
import { getFirestore } from "firebase/firestore";
import { getAuth, GoogleAuthProvider, onAuthStateChanged } from "firebase/auth";
project under its own project settings
const firebaseConfig = {
apiKey: process.env.REACT_APP_apiKey,
authDomain: process.env.REACT_APP_authDomain,
projectId: process.env.REACT_APP_projectId,
storageBucket: process.env.REACT_APP_storageBucket,
messagingSenderId: process.env.REACT_APP_messagingSenderId,
appId: process.env.REACT_APP_appId,
};
//Initializing Firebase
const app = initializeApp(firebaseConfig);
This is the error:
The Package.json:
Make sure your .env.local is placed in the root directory, and not in any subfolders like src or public. Other than that, nothing seems to be wrong with your code. Just to be safe, cross check your API key with firebase.
P.S. There's no need to hide your firebase public API key, its going to be visible in your app to the general public anyway.

firebase import error with node, react and Chakra [duplicate]

This question already has answers here:
Firebase Analytics with Next.js - window not definded
(2 answers)
Closed 8 months ago.
So I am receiving this error when I run "yarn dev" in the projects directory.
code (firebaseConfig.js):
// Import the functions you need from the SDKs you need
import { initializeApp } from "firebase/app";
import { getAnalytics } from "firebase/analytics";
import { getAuth } from "firebase/auth";
// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
const firebaseConfig = {
apiKey:
authDomain:
databaseURL:
projectId:
storageBucket:
messagingSenderId:
appId:
measurementId:
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
const analytics = getAnalytics(app);
const auth = getAuth();
export { auth }
Does anyone know why?
if anyone is wondering, i just deleted my analytics and then it worked, don't even know why i got that error

Expo - Remote Config: Indexed DB is not supported by current browser

I have an expo app and tried to add Firebase support to use their remote-config service. I am testing it in this code
// Import the functions you need from the SDKs you need
import { initializeApp } from "firebase/app";
import { getAnalytics } from "firebase/analytics";
import { getRemoteConfig } from "firebase/remote-config";
// TODO: Add SDKs for Firebase products that you want to use
// https://firebase.google.com/docs/web/setup#available-libraries
// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
const firebaseConfig = {
apiKey: "aaaaaaaaaaaaaaaaaaa",
authDomain: "bbbbbbbbbbbbbbbb",
projectId: "ccccccccccc",
storageBucket: "ddddddddddddddddddddddddddd",
messagingSenderId: "eeeeeeeeeeeeeeeee",
appId: "fffffffffffffffffffff",
measurementId: "gggggggggggggggggg"
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
const analytics = getAnalytics(app);
export const config = getRemoteConfig(app);
config.settings.minimumFetchIntervalMillis = 3600000;
config.defaultConfig = {
"test": "Welcome222222"
};
config.getValue("test");
But when i try to run it in Expo Go on Android emulator, i get
FirebaseError: Remote Config: Indexed DB is not supported by current browser (remoteconfig/indexed-db-unavailable)
Is there a way to not use any Indexed DB? I thought that the library would just let me use the remote config REST api confortably and i could just send requests, i have no need for any DB in this case.

using the environment variable, Firebase invalid api key error in console

I am using Google Sign In, Firebase, and React firebase hook to login react web application.
inserting firebaseConfig API (.env.local) file and setting the secret keys to firebase config causes errors on the console
.env.local
REACT_APP_AUTH_DOMAIN=doctors-portal-6bc13.firebaseapp.com
REACT_APP_PROJECT_ID=doctors-portal-6bc13
REACT_APP_STORAGE_BUCKET=doctors-portal-6bc13.appspot.com
REACT_APP_MESSAGING_SENDER_ID=725454304359
REACT_APP_APP_ID=1:725454304359:web:49840cbf09a6b578e210c2```
firebase.init.js file
import { initializeApp } from "firebase/app";
import {getAuth } from "firebase/auth";
const firebaseConfig = {
apiKey: process.env.REACT_APP_API_KEY,
authDomain: process.env.REACT_APP_AUTH_DOMAIN,
projectId: process.env.REACT_APP_PROJECT_ID,
storageBucket: process.env.REACT_APP_STORAGE_BUCKET,
messagingSenderId: process.env.REACT_APP_MESSAGING_SENDER_ID,
appId: process.env.REACT_APP_APP_ID,
};
const app = initializeApp(firebaseConfig);
const auth = getAuth(app);
export default auth;```
Works directly when using Firebase API without using (.env.local)
const firebaseConfig = {
apiKey: "AIzaSyA72Jfi_WXWie-i641mAYhLv3QgiynzLxQ",
authDomain: "doctors-portal-6bc13.firebaseapp.com",
projectId: "doctors-portal-6bc13",
storageBucket: "doctors-portal-6bc13.appspot.com",
messagingSenderId: "725454304359",
appId: "1:725454304359:web:49840cbf09a6b578e210c2",
};
writting like this does not give any error
try this: https://i.stack.imgur.com/xH4Dm.png
You have to place your .env path between `${
It works for me.
I had the same issue.
You just need to Restart the Server.
Close the server and start again with npm start.
This just worked fine for me.
(Every time you create or change anything in your .env file, you need to start the server again )

Categories