javascriptfirebasefirebase-authenticationgoogle-signin

firebase/init.json 404 - While using signInWithPopup for Google Login


firebase/init.json shows 404 - While using signInWithPopup for Google Login . I am using authdomain with firebaseapp.com itself.

"use client";
import { Container, Button, Typography, Box, CircularProgress } from '@mui/material';
import { initializeApp } from "firebase/app";
import { getAuth, getRedirectResult, GoogleAuthProvider, signInWithCredential, signInWithPopup, signInWithRedirect } from "firebase/auth";
import axios from "./utils/axiosInstance";
import { useEffect, useState } from 'react';
import { useRouter } from 'next/navigation'

export default function Login() {
    const [inprogress, setInProgress] = useState(false);
    const [loginResponse, setLoginResponse] = useState<any | null>(null);

    const router = useRouter()

    const firebaseConfig = {
        apiKey: "xxxxxxxxxxxxxxxxxxxxxxxxx",
        authDomain: "xxxxxx.firebaseapp.com",
        projectId: "xxxxxx",
        storageBucket: "xxxxx.firebasestorage.app",
        messagingSenderId: "xxxxxx",
        appId: "xxxxxxxxxxx",
        measurementId: "xxxxxx"
      };

    const app = initializeApp(firebaseConfig);
    const auth = getAuth(app);

    getRedirectResult(auth).then((data)=>{
        console.log(data)
    })

    const signInWithGoogle = async () => {
        try {
            setInProgress(true)
            const provider = new GoogleAuthProvider();
            await signInWithRedirect(auth, provider);
        } catch (error) {
        }
    };

    return (
        <Container maxWidth="xs">
            ...
        </Container>
    );
}

Solution

  • I resolved this issue by migrating to oAuth2