Dropbox OAuth窗口不起作用 [英] Dropbox oauth window is not working
问题描述
我正在将我的应用程序移植到Electron,我惊讶地发现Dropbox身份验证在这种环境下不起作用。
I'm porting my application to Electron and I was surprised to find out that the Dropbox authentication doesn't work in this environment. It does work in Chrome though.
登录按钮保持禁用状态,并且标签显示在输入上方。
The sign-in buttons remain disabled and the labels appear over the inputs.
以下消息将显示在控制台中:
The following message is displayed in the console:
Content-Security-Policy指令'worker-src'在标志后面实现
The Content-Security-Policy directive 'worker-src' is implemented behind a flag which is currently disabled.
我正在OS X上使用dropbox @ 2.5.7,electron @ 1.7.7进行测试。
I'm testing using dropbox@2.5.7, electron@1.7.7 on OS X.
我发现了类似的问题,但似乎使用了不同版本的Electron并具有不同的错误消息:
I found a similar question, but it seems to use a different version of Electron and has a different error message:
更新:
Content-Securi ty-Policy
消息似乎与Chrome版本有关。在Chrome 59中引入了 worker-src
指令,Chrome 58附带了electronic@1.7.7。
The Content-Security-Policy
message seems to be related to the Chrome version. The worker-src
directive was introduced in Chrome 59 and electron@1.7.7 is shipped with Chrome 58.
https://www.chromestatus.com/feature/5922594955984896
我已经测试了Chrome 59附带的electronic@1.8.0,并且控制台消息消失了。但是auth页面的问题仍然存在。
I've tested with electron@1.8.0 that comes with Chrome 59, and the console messages are gone. But the problem with the auth page remains.
推荐答案
这是因为 BrowserWindow
默认情况下启用了 nodeIntergration
标志。这与 Dropbox
捆绑在一起的 RequireJS
实现冲突。
This happens because BrowserWindow
has the nodeIntergration
flag enabled by default. And this conflicts with the RequireJS
implementation with which Dropbox
was bundled.
因此解决方案是在创建浏览器窗口时禁用 nodeIntergration
:
So the solution would be to disable nodeIntergration
when creating the browser window:
const win = new electron.BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: false
}
});
win.loadURL(link);
这是一个小型演示项目:
> https://github.com/kenjiru/electron-dropbox-sample-app
Here's a small demo project: https://github.com/kenjiru/electron-dropbox-sample-app
这篇关于Dropbox OAuth窗口不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!