繁体   English   中英

Reactjs 用户认证 firebase

[英]Reactjs user Authentication with firebase

我正在 Reactjs 和 firebase 中使用谷歌登录方法进行用户身份验证系统,因为我认为我的代码没有任何问题,但是当我单击按钮时,弹出窗口显示并立即关闭,我的控制台中的错误是:

FirebaseError:Firebase:错误(授权/未授权域)。

我去了 firebase 控制台 > 身份验证 > 登录方法来授权域,但看不到我可以把我的域放在哪里

对不起,我的英语不是我的第一语言

我的代码,我正在使用 vite 创建反应项目

// 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)

        });
}
   

firebase 控制台>认证>设置+授权域

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM