Dropbox oauth window is not working

£可爱£侵袭症+ 提交于 2020-01-14 13:16:28

问题


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:

The Content-Security-Policy directive 'worker-src' is implemented behind a flag which is currently disabled.

I'm testing using dropbox@2.5.7, electron@1.7.7 on OS X.

I found a similar question, but it seems to use a different version of Electron and has a different error message:

Dropbox oauth view is not rendering properly


Update:

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

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.


回答1:


This happens because BrowserWindow has the nodeIntergration flag enabled by default. And this conflicts with the RequireJS implementation with which Dropbox was bundled.

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);

Here's a small demo project: https://github.com/kenjiru/electron-dropbox-sample-app



来源:https://stackoverflow.com/questions/46124442/dropbox-oauth-window-is-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!