无法在电子应用程序中使用Discord

无法在电子应用程序中使用Discord

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

问题描述

我正在尝试使用Discord的OAuth2创建带有用户登录的Electron应用程序(使用Electron.net和MVC).但是,在加载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
        }
});

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

08-01 19:09