Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Reactjs user Authentication with firebase

i’m doing a user authentication system in Reactjs with firebase with google signin method, as I think my code does not have any problem, but when I click in the button the Popup shows and close immediatly and the error in my console is:

FirebaseError: Firebase: Error (auth/unauthorized-domain).

I went to firebase console > Authentication > Sign-In-Method to authorize domain, and can’t see where I can put my domain

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Sorry my English it’s not my first language

my code, I’m using vite to create react project

// Import the functions you need from the SDKs you need
import { initializeApp } from "firebase/app";
import { getAuth, signInWithPopup, GoogleAuthProvider } from "firebase/auth";

// Your web app's Firebase configuration
const firebaseConfig = {
    apiKey: "AIzaSyBPbVyiVcN4K7cmMSo1QsPJQeIxZUZ7yCE",
    authDomain: "social-app-bc20f.firebaseapp.com",
    projectId: "social-app-bc20f",
    storageBucket: "social-app-bc20f.appspot.com",
    messagingSenderId: "426481165558",
    appId: "1:426481165558:web:07720e6132e0d91c21b8d7"
};

// Initialize Firebase
const app = initializeApp(firebaseConfig);
const provider = new GoogleAuthProvider();

export const auth = getAuth();

export const signInWithGoogle = () => {
    signInWithPopup(auth, provider)
        .then((result) => {
            // ...
            console.log(result)
        }).catch((error) => {
            // Handle Errors here.
            console.log(error)

        });
}
   

>Solution :

firebase console > Authentication > Settings +to authorize domain

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading