Firebase Google 身份验证窗口弹出关闭错误延迟

问题描述 投票:0回答:1

简短而甜蜜:

  • 关闭/关闭
    Google
    登录弹出窗口(键盘命令或点击 X)时,为什么收到
    (auth/popup-closed-by-user)
    错误几乎延迟了 7 秒?.

这里有什么想法吗?我希望它立即抛出错误......出于多种原因。

我已经多次测试过这一点,但它总是延迟。在 MacBook Pro 2021 上运行 Safari 17.2.1


import { initializeApp } from 'https://www.gstatic.com/firebasejs/10.10.0/firebase-app.js'
import { getAuth, signInWithPopup, GoogleAuthProvider, getAdditionalUserInfo } from 'https://www.gstatic.com/firebasejs/10.10.0/firebase-auth.js'

const firebaseConfig = {
    apiKey: "********",
    authDomain: "********"
  }

const app = initializeApp(firebaseConfig);
const auth = getAuth(app);
const provider = new GoogleAuthProvider()

export function signInWithGoogle(callback) {
    auth.languageCode = 'it'
    signInWithPopup(auth, provider)
        .then((result) => {

            const credential = GoogleAuthProvider.credentialFromResult(result)
            const token = credential.accessToken
            const user = result.user
            const { isNewUser } = getAdditionalUserInfo(result) 
            callback(null, user, isNewUser)

        }).catch((error) => {

            const errorCode = error.code
            const errorMessage = error.message
            const email = error.customData.email
            const credential = GoogleAuthProvider.credentialFromError(error)
            console.log(errorMessage)
            callback(error, null, false)

        })

}
javascript firebase error-handling google-oauth
1个回答
0
投票

从这个github问题中,轮询过程检查弹出窗口是否关闭,并将其超时从2秒增加到8秒以解决firefox中的问题,因此出现延迟。

© www.soinside.com 2019 - 2024. All rights reserved.