gpt4 book ai didi

firebase - 为什么我的 Firebase Google Auth 弹出窗口会立即关闭?

转载 作者:行者123 更新时间:2023-12-03 19:45:17 25 4
gpt4 key购买 nike

我关注 this tutorial学习火力基地。我克隆了the repo .在第 7 步,我按照它所说的做了(尽管实际上,这里没有什么可做的,因为这些步骤已经在 repo 中完成了)。当我单击 UI 中的 [SIGN-IN WITH GOOGLE] 按钮时,身份验证窗口会弹出并立即关闭。

我正在 VMWare 中的 Ubuntu guest 中开发。在 Firebase 控制台中为该应用授权了以下域:

  • 本地主机
  • blahblah.firebaseapp.com
  • 127.0.0.1
  • <我的访客ip>
  • <我的主机/公共(public)IP>

  • firebase网站说在这里问。我 searched thouroughly首先,(少数)其他发布的解决方案不起作用。

    谁能告诉我为什么会这样?

    最佳答案

    很抱歉回复晚了,即使您决定进一步使用其他服务提供商,以下内容可能对遇到相同问题的其他人有所帮助。

    弹出窗口可能会在打开后立即关闭,因为您可以使用此处的步骤 5 捕获该错误:https://firebase.google.com/docs/auth/web/google-signin

    这是一个简短的片段,只需修改 public/scripts/main.js 中的 signInWithPopup 函数:

    firebase.auth().signInWithPopup(provider).then(function(result) {
    // code which runs on success
    }).catch(function(error) {
    // Handle Errors here.
    var errorCode = error.code;
    console.log(errorCode);
    alert(errorCode);

    var errorMessage = error.message;
    console.log(errorMessage);
    alert(errorMessage);
    });

    根据我的经验,errorCode 可能类似于“auth/unauthorized-domain”,而 errorMessage 可能指向您正在访问的受限域:
    “此域 (127.0.0.1) 无权运行此操作。将其添加到 Firebase 控制台 -> 身份验证部分 -> 登录方法选项卡中的 OAuth 重定向域列表中。”

    我的解决方案是使用 localhost:8080 而不是 127.0.0.1:8080,但是也可以使用 errorMessage 中的说明将 127.0.0.1 添加到受信任的域。

    您的错误可能会有所不同,但希望它有助于调试。谢谢。

    关于firebase - 为什么我的 Firebase Google Auth 弹出窗口会立即关闭?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55250189/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com