繁体   English   中英

如何在 Electron/Firebase 应用程序中支持 HTTP 协议

[英]How to support HTTP protocol in Electron/Firebase App

我正在尝试在我的 Electron 应用程序中使用 firebase 身份验证(saml)。 我读过 Electron 不是“官方支持”的,但是我也遇到了一些线程表明人们已经让它工作了。 我的问题是在使用firebase.auth().signInWithRedirect (或signInWithPopup )时,出现错误:

 code: "auth/operation-not-supported-in-this-environment"
 message: "This operation is not supported in the environment this application
 is running on. "location.protocol" must be http, https or chrome-extension and 
 web storage must be enabled."

谷歌出现了这篇提示和技巧文章,它建议只使用托管的 URL:

第三,OAuth 请求需要有可验证的来源,可以在 Firebase 控制台中加入白名单。 这需要当前的 Electron 浏览器 window 使用 http 或 Z5E056C500A1C4B6A7110B5DEBADE.07 协议,而不是文件。 That means the current window contents should be loaded with browserWindow.loadURL and not browserWindow.loadFile, and the url must be an http or https url, not a file:// url. 这通常需要一个托管页面,该页面被包装到 Electron window 中。

这可能会起作用,因为只需在 angular 开发服务器上本地运行应用程序,只需使用:

mainWindow.loadURL('http://localhost:4200');

我不想这样做,因为拥有托管页面会大大降低拥有原生应用程序的吸引力。

我可以通过让一个本地 Node/Express 实例在本地使用get-port为应用程序提供服务来找到一个空闲端口来在那里运行应用程序来完成这项工作。 我还没有真正看到任何例子表明这一点。 有一些关于让它工作的 Stackoverflow 问题,但没有什么让我认为它是一个可接受的生产级解决方案。

本地 Express 服务器是规避此错误的可接受方式,还是目前有更好的解决方案?

注意:此答案中推荐的 package不是由 Firebase 发布的,而且它看起来也不支持 SAML 身份验证。

i've successfuly implemented firebase email ver in my app, it is more feasible to load.html file rather than load a page from url as users can exploit the the url by sending fake data. but with oauth it is not possible,firebase create webapp you can create a html file it should contain api keys, host url etc and host it locally in android file://android_assets/filename.html this works fine even offline i dont know properly关于 electron

暂无
暂无

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

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