Dropbox oauth window is not working

2019-06-24 07:05发布

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.

Console messages

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条回答
Root(大扎)
2楼-- · 2019-06-24 07:46

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

查看更多
登录 后发表回答