无法在 Electron 应用程序中使用 Discord OAuth2

2

本文介绍了无法在 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

C# 中的多播委托奇怪行为?
Multicast delegate weird behavior in C#?(C# 中的多播委托奇怪行为?)...
2023-11-11 C#/.NET开发问题
6

参数计数与调用不匹配?
Parameter count mismatch with Invoke?(参数计数与调用不匹配?)...
2023-11-11 C#/.NET开发问题
26

如何将代表存储在列表中
How to store delegates in a List(如何将代表存储在列表中)...
2023-11-11 C#/.NET开发问题
6

代表如何工作(在后台)?
How delegates work (in the background)?(代表如何工作(在后台)?)...
2023-11-11 C#/.NET开发问题
5

没有 EndInvoke 的 C# 异步调用?
C# Asynchronous call without EndInvoke?(没有 EndInvoke 的 C# 异步调用?)...
2023-11-11 C#/.NET开发问题
2

Delegate.CreateDelegate() 和泛型:错误绑定到目标方法
Delegate.CreateDelegate() and generics: Error binding to target method(Delegate.CreateDelegate() 和泛型:错误绑定到目标方法)...
2023-11-11 C#/.NET开发问题
14