Firebase Auth + Electron =失败?

时间:2018-05-15 12:11:31

标签: firebase firebase-authentication electron

我试图让firebase auth使用电子。我已经将它与iOS和Android配合使用,并希望在应用程序的桌面版本中使用它。

我主要尝试的是谷歌登录。使用firebase的网络版本最终导致localhost无法接受登录失败。我试过了node.js代码的版本,但我也无法正常工作。

谷歌:https://www.google.com/search?q=firebase+auth+electron

你会看到我所尝试过的所有内容以及我查看过的所有stackoverflow问题。有人说他们有工作,但我没有发现任何有效的例子。这是一个失败的原因还是有人指出我正确的方向?

很多人似乎都有同样的问题,但没有答案。

4 个答案:

答案 0 :(得分:0)

Firebase Auth + Electron =很难!

我得到这个工作的一种方法是通过Electrons main.js通过http提供html和javascript。确保使用localhost而不是127.0.0.1,然后Firebase通过web(而不是node.js)的Google Signin应该可以使用。

答案 1 :(得分:0)

您必须在主窗口的var stylesheet = document.createElement("link"); stylesheet.rel = "stylesheet"; stylesheet.type = "text/css"; stylesheet.href = "your_file.css"; document.head.appendChild(stylesheet); 内将nativeWindowOpen设置为true。像这样:

webPreferences

答案 2 :(得分:0)

您可以寻找的是可以满足您的需求但不能完全满足您需求的东西。虽然google登录模块很难说到电子,但我已经发现将createUserWithEmailAndPassword函数与Firebase auth结合使用是成功的,请确认

答案 3 :(得分:0)

在将Firebase和electronic.js与React.js连接时,我遇到了同样的问题,但是有一种简单的方法可以让您使用Firebase弹出式身份验证。在主过程中创建新的browserWindow时。在 webPreferences 对象下,添加或设置属性 nativeWindowOpen 为true。 确保您的webPreferences对象的nativeWindowOpen属性设置为true。

示例

window = new electron.BrowserWindow({
    width: 1200,
    height: 650,
   webPreferences:{
       nodeIntegration: true,
       enableRemoteModule: true,
       nativeWindowOpen: true, // this allows you to use popups when doing authentication using firebase in an electron app
   }
})

祝你好运✔✔✨✨

相关问题