无法在 Electron 应用程序中使用 Discord OAuth2 [英] Can't use Discord OAuth2 in Electron application

查看:31
本文介绍了无法在 Electron 应用程序中使用 Discord OAuth2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个 Electron 应用程序(使用 Electron.net 和 MVC),并使用 Discord 的 OAuth2 进行用户登录.但是,在加载 OAuth2 页面时,Discord 认为我使用的是损坏的 Discord 安装.我认为这是因为 Discord 桌面应用程序也使用了 Electron.不使用 Electron 时,链接可以正常打开.

I'm trying to create an Electron app (using Electron.net and MVC) with user sign-ins using Discord's OAuth2. However when loading up the OAuth2 page, Discord thinks that I'm using a broken installation of Discord. I assume that this is because the Discord desktop application also uses Electron. When not using Electron, the link opens fine.

到目前为止,我已经尝试更改 Electron 使用的 User-Agent(在 Electron 启动代码中和直接在与 Javascript 的链接上),因为我相信这就是 Discord 将应用程序识别为使用 Electron 的方式,但是这没有奏效.有谁知道 Discord 可能会如何解决我正在使用 Electron 以及如何解决它?

So far I've attempted changing the User-Agent (both in the Electron startup code and directly on the link with Javascript) used by Electron as I believed that this was how Discord was identifying the app as using Electron, however this hasn't worked. Does anyone know how else Discord might be working out that I'm using Electron and how I might get around it?

不确定它是否增加了很多,但这是我尝试时遇到的错误的屏幕截图进入 Discord 登录页面.

推荐答案

我不得不处理同样的问题,所以我在加载时启用了 devtools.我在这里找到了这个脚本(https://discordapp.com/assets/db6c3ddb51620cee5d94.js)他们在哪里处理应用程序事件,我意识到他们正在加载节点模块,这在浏览器设置中是不可用的.解决方案是在窗口选项中设置 nodeIntegration: false,如下所示:

I had to deal with the same issue, so I enabled devtools on load. I found this script here (https://discordapp.com/assets/db6c3ddb51620cee5d94.js) where they handle the app events, and I realized that they were loading node modules, which would not be available in a browser setting. The solution is to set nodeIntegration: false in the window options like so:

authWindow = new BrowserWindow({
        width: 800,
        height: 500,
        frame: false,
        webPreferences: {
            nodeIntegration: false
        }
});

这篇关于无法在 Electron 应用程序中使用 Discord OAuth2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆